lib/load_speed.rb in stopwatch-0.0.4 vs lib/load_speed.rb in stopwatch-1.0.0
- old
+ new
@@ -12,10 +12,13 @@
body = ""
response.each {|part| body << part}
index = body.rindex("</body>")
if index
body.insert(index, performance_code)
- headers["Content-Length"] = body.length.to_s
+ #
+ # handle body w/ UTF8 characters for Ruby 1.9+ to avoid Rack::Lint::LintError
+ #
+ headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.length).to_s
response = [body]
end
end
[status, headers, response]