From e166cfe5e8d648b544b1291ec157bd234a425e21 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 8 Feb 2013 22:45:20 +0000 Subject: hijacking support for Rack 1.5.x users This requires Rack 1.5.x and unicorn 4.6.0 for hijacking support. Older versions of Rack continue to work fine, but we must use unicorn 4.6.0 features to support this. --- lib/rainbows/ev_core.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/ev_core.rb') diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb index 46feaff..5c3c5b8 100644 --- a/lib/rainbows/ev_core.rb +++ b/lib/rainbows/ev_core.rb @@ -52,16 +52,17 @@ module Rainbows::EvCore end # returns whether to enable response chunking for autochunk models - def stream_response_headers(status, headers, alive) + # returns nil if request was hijacked in response stage + def stream_response_headers(status, headers, alive, body) headers = Rack::Utils::HeaderHash.new(headers) unless Hash === headers if headers.include?(Content_Length) - write_headers(status, headers, alive) + write_headers(status, headers, alive, body) or return return false end case @env[HTTP_VERSION] when "HTTP/1.0" # disable HTTP/1.0 keepalive to stream - write_headers(status, headers, false) + write_headers(status, headers, false, body) or return @hp.clear false when nil # "HTTP/0.9" @@ -69,7 +70,7 @@ module Rainbows::EvCore else rv = !!(headers[Transfer_Encoding] =~ %r{\Achunked\z}i) rv = false unless @env["rainbows.autochunk"] - write_headers(status, headers, alive) + write_headers(status, headers, alive, body) or return rv end end -- cgit v1.2.3-24-ge0c7