Skip to content

Commit

Permalink
fix Content-Length incorrect in Ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
quark-zju committed Apr 3, 2012
1 parent 3328638 commit 8abd234
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/rack/bug/toolbar.rb
@@ -1,3 +1,12 @@
# we need 'bytesize' for String, which does not exists and is 'size' in Ruby 1.8
unless String.instance_methods.include? :bytesize
class String
def bytesize
size
end
end
end

module Rack
class Bug
class Toolbar
Expand Down Expand Up @@ -49,7 +58,7 @@ def inject_toolbar

full_body.sub! /<\/body>/, toolbar + "</body>"

@response["Content-Length"] = full_body.size.to_s
@response["Content-Length"] = full_body.bytesize.to_s

# Ensure that browser does
@response["Etag"] = ""
Expand Down

0 comments on commit 8abd234

Please sign in to comment.