diff options
-rw-r--r-- | lib/unicorn.rb | 4 | ||||
-rw-r--r-- | lib/unicorn/app/exec_cgi.rb | 6 | ||||
-rw-r--r-- | lib/unicorn/app/inetd.rb | 7 | ||||
-rw-r--r-- | lib/unicorn/cgi_wrapper.rb | 2 | ||||
-rw-r--r-- | lib/unicorn/http_request.rb | 2 | ||||
-rw-r--r-- | lib/unicorn/tee_input.rb | 4 |
6 files changed, 10 insertions, 15 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 392d301..de61c09 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -15,10 +15,6 @@ module Unicorn autoload :TeeInput, 'unicorn/tee_input' autoload :Util, 'unicorn/util' - Z = '' # the stock empty string we use everywhere... - Z.force_encoding(Encoding::BINARY) if Z.respond_to?(:force_encoding) - Z.freeze - class << self def run(app, options = {}) HttpServer.new(app, options).start.join diff --git a/lib/unicorn/app/exec_cgi.rb b/lib/unicorn/app/exec_cgi.rb index 4f9216b..2262e4c 100644 --- a/lib/unicorn/app/exec_cgi.rb +++ b/lib/unicorn/app/exec_cgi.rb @@ -125,10 +125,10 @@ module Unicorn::App else tmp = Unicorn::Util.tmpio - buf = Unicorn::Z.dup - while inp.read(CHUNK_SIZE, buf) + buf = inp.read(CHUNK_SIZE) + begin tmp.syswrite(buf) - end + end while inp.read(CHUNK_SIZE, buf) tmp.sysseek(0) tmp end diff --git a/lib/unicorn/app/inetd.rb b/lib/unicorn/app/inetd.rb index f751a33..9bfa7cb 100644 --- a/lib/unicorn/app/inetd.rb +++ b/lib/unicorn/app/inetd.rb @@ -33,13 +33,12 @@ module Unicorn::App inp_pid = fork { input = env['rack.input'] [ err_rd, out_rd ].each { |io| io.close } - buf = Unicorn::Z.dup # this is dependent on input.read having readpartial semantics: - while input.read(16384, buf) + buf = input.read(16384) + begin in_wr.write(buf) - end - in_wr.close + end while input.read(16384, buf) } in_wr.close self.pid_map = { diff --git a/lib/unicorn/cgi_wrapper.rb b/lib/unicorn/cgi_wrapper.rb index 64848b4..729efee 100644 --- a/lib/unicorn/cgi_wrapper.rb +++ b/lib/unicorn/cgi_wrapper.rb @@ -59,7 +59,7 @@ class Unicorn::CGIWrapper < ::CGI @status = nil @head = {} @headv = Hash.new { |hash,key| hash[key] = [] } - @body = StringIO.new + @body = StringIO.new("") super(*args) end diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index 4a78e73..1d978e6 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -19,7 +19,7 @@ module Unicorn "SERVER_SOFTWARE" => "Unicorn #{Const::UNICORN_VERSION}" } - NULL_IO = StringIO.new(Z) + NULL_IO = StringIO.new("") LOCALHOST = '127.0.0.1' # Being explicitly single-threaded, we have certain advantages in diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 36a76ed..96a053a 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -15,7 +15,7 @@ module Unicorn def initialize(*args) super(*args) @size = parser.content_length - @tmp = @size && @size < Const::MAX_BODY ? StringIO.new(Z.dup) : Util.tmpio + @tmp = @size && @size < Const::MAX_BODY ? StringIO.new("") : Util.tmpio @buf2 = buf.dup if buf.size > 0 parser.filter_body(@buf2, buf) and finalize_input @@ -46,7 +46,7 @@ module Unicorn length = args.shift if nil == length - rv = @tmp.read || Z.dup + rv = @tmp.read || "" while tee(Const::CHUNK_SIZE, @buf2) rv << @buf2 end |