Skip to content

Commit

Permalink
Merge pull request #2 from ncareol/fix-ruby19-string-length
Browse files Browse the repository at this point in the history
Content-Length: handle body w/ UTF8 characters for Ruby 1.9+ to avoid Rack::Lint::LintError
  • Loading branch information
bittersweet authored Feb 9, 2017
2 parents 5930446 + e05dfde commit 413b527
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/load_speed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def call(env)
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
Expand Down

0 comments on commit 413b527

Please sign in to comment.