21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/rack/minify.rb', line 21
def _call(env)
status, , response = @app.call(env)
= HeaderHash.new()
if !STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
!['transfer-encoding'] &&
['content-type'] &&
['content-type'].include?("text/html")
body = ""
response.each { |part| body += part }
start, size_before = Time.now, body.size if @bench
html = HtmlMini.minify(body) rescue nil
stop = Time.now and log(env, (stop-start).seconds, size_before, html.size) if @bench
['Content-Length'] = html.size.to_s
['Html-Mini'] = "version #{HtmlMini::VERSION}, time #{(stop-start).seconds}s, size #{html.size-size_before} bytes" if @bench
response = [html] unless html.nil?
end
[status, , response]
end
|