From 4716aab9530cabb14448a5123865b9f79b77f40c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 30 May 2009 09:15:50 -0700 Subject: http_request: StringIO is binary for empty bodies (1.9) --- lib/unicorn/http_request.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/unicorn/http_request.rb') 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 -- cgit v1.2.3-24-ge0c7