From 1e6d3d19da2b62bfe7f8fd7827dcad3ee3fe9923 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Jul 2010 10:09:56 +0000 Subject: rev + em: more easily allow Content-Length in pipe responses If a response proxying a pipe (or socket) includes a Content-Length, do not attempt to outsmart the application and just use the given Content-Length. This helps avoid exposing applications to weird internals such as env["rainbows.autochunk"] and X-Rainbows-* response headers. --- lib/rainbows/event_machine.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'lib/rainbows/event_machine.rb') diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 625357e..86cb4eb 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -50,7 +50,6 @@ module Rainbows class Client < EM::Connection # :nodoc: all include Rainbows::EvCore - include Rainbows::Response G = Rainbows::G def initialize(io) @@ -98,14 +97,7 @@ module Rainbows # used for streaming sockets and pipes def stream_response(status, headers, io) - if headers - do_chunk = !!(headers['Transfer-Encoding'] =~ %r{\Achunked\z}i) - do_chunk = false if headers.delete('X-Rainbows-Autochunk') == 'no' - headers[CONNECTION] = CLOSE # TODO: allow keep-alive - write(response_header(status, headers)) - else - do_chunk = false - end + do_chunk = stream_response_headers(status, headers) if headers mod = do_chunk ? ResponseChunkPipe : ResponsePipe EM.watch(io, mod, self).notify_readable = true end -- cgit v1.2.3-24-ge0c7