diff options
Diffstat (limited to 'lib/unicorn/app/exec_cgi.rb')
-rw-r--r-- | lib/unicorn/app/exec_cgi.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/unicorn/app/exec_cgi.rb b/lib/unicorn/app/exec_cgi.rb index d98b3e4..8f81d78 100644 --- a/lib/unicorn/app/exec_cgi.rb +++ b/lib/unicorn/app/exec_cgi.rb @@ -95,10 +95,15 @@ module Unicorn::App # Allows +out+ to be used as a Rack body. def out.each sysseek(@unicorn_app_exec_cgi_offset) + + # don't use a preallocated buffer for sysread since we can't + # guarantee an actual socket is consuming the yielded string + # (or if somebody is pushing to an array for eventual concatenation begin - loop { yield(sysread(CHUNK_SIZE)) } + yield(sysread(CHUNK_SIZE)) rescue EOFError - end + return + end while true end prev = nil @@ -126,7 +131,8 @@ module Unicorn::App tmp.binmode # Rack::Lint::InputWrapper doesn't allow sysread :( - while buf = inp.read(CHUNK_SIZE) + buf = '' + while inp.read(CHUNK_SIZE, buf) tmp.syswrite(buf) end tmp.sysseek(0) |