about summary refs log tree commit homepage
path: root/extras
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-11-12 21:14:06 +0000
committerEric Wong <e@80x24.org>2013-11-12 21:14:06 +0000
commitf7c45b50ae9c042ba8bd78658ba8132fdaf96096 (patch)
treea79fb7d4003314081ecce5bdfaef886b6fece444 /extras
parent7dbf0de3f00d6400526f7742904d56cd5eb5629b (diff)
downloadyahns-f7c45b50ae9c042ba8bd78658ba8132fdaf96096.tar.gz
Leave that up to Rack::Chunked/Rack::ContentLength.
Chunking ourselves interacts badly with Rack::Deflater, since
Deflater will blindly deflate already-chunked portions.
Diffstat (limited to 'extras')
-rw-r--r--extras/exec_cgi.rb17
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