diff options
Diffstat (limited to 'extras/exec_cgi.rb')
-rw-r--r-- | extras/exec_cgi.rb | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb index 89fc9b4..39042af 100644 --- a/extras/exec_cgi.rb +++ b/extras/exec_cgi.rb @@ -8,19 +8,15 @@ class ExecCgi class MyIO < Kgio::Pipe attr_writer :my_pid attr_writer :body_tip - attr_writer :chunked def each buf = @body_tip || "" if buf.size > 0 - buf = "#{buf.size.to_s(16)}\r\n#{buf}\r\n" if @chunked yield buf end while tmp = kgio_read(8192, buf) - tmp = "#{tmp.size.to_s(16)}\r\n#{tmp}\r\n" if @chunked yield tmp end - yield("0\r\n\r\n") if @chunked self ensure # do this sooner, since the response body may be buffered, we want @@ -90,7 +86,8 @@ class ExecCgi end head, body = head.split(/\r?\n\r?\n/) pipe.body_tip = body - pipe.chunked = false + + env["HTTP_VERSION"] ||= "HTTP/1.0" # stop Rack::Chunked for HTTP/0.9 headers = Rack::Utils::HeaderHash.new prev = nil @@ -101,16 +98,6 @@ class ExecCgi end end status = headers.delete("Status") || 200 - unless headers.include?("Content-Length") || - headers.include?("Transfer-Encoding") - case env['HTTP_VERSION'] - when 'HTTP/1.0', nil - # server will drop connection anyways - else - headers["Transfer-Encoding"] = "chunked" - pipe.chunked = true - end - end errbody = nil [ status, headers, pipe ] else |