summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-30 09:15:50 -0700
committerEric Wong <normalperson@yhbt.net>2009-05-31 01:34:13 -0700
commit4716aab9530cabb14448a5123865b9f79b77f40c (patch)
tree8c9db78423b234ba158e1ad53f2186c6ef1f0581
parent34b916e3c237f32d5455869d2823eccb27e9ff24 (diff)
-rw-r--r--lib/unicorn/http_request.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 115926b..24f8247 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -29,7 +29,9 @@ module Unicorn
 
     # Optimize for the common case where there's no request body
     # (GET/HEAD) requests.
-    NULL_IO = StringIO.new
+    Z = ''
+    Z.force_encoding(Encoding::Binary) if Z.respond_to?(:force_encoding)
+    NULL_IO = StringIO.new(Z)
     LOCALHOST = '127.0.0.1'.freeze
 
     # Being explicitly single-threaded, we have certain advantages in
@@ -104,7 +106,8 @@ module Unicorn
       content_length = PARAMS[Const::CONTENT_LENGTH].to_i
 
       if content_length == 0 # short circuit the common case
-        PARAMS[Const::RACK_INPUT] = NULL_IO.closed? ? NULL_IO.reopen : NULL_IO
+        PARAMS[Const::RACK_INPUT] =
+            NULL_IO.closed? ? NULL_IO.reopen(Z) : NULL_IO
         return PARAMS.update(DEFAULTS)
       end