Permalink
Browse files

fix Content-Length incorrect in Ruby 1.9

  • Loading branch information...
1 parent 3328638 commit 8abd23456ef1b9f3dbd548f6031523285505c021 @quark-zju quark-zju committed Apr 3, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 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
@@ -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"] = ""

0 comments on commit 8abd234

Please sign in to comment.