From 090829a95ba4e3c6fe4562c9feb8fde5382a44f4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 May 2015 19:57:44 +0000 Subject: http_response: avoid special-casing for Rack < 1.5 Rack 1.4 and earlier will soon die out, so avoid having extra, overengineered code and method dispatch to silently drop support for mis-hijacking with old Rack versions. This will cause improperly hijacked responses in all versions of Rack to fail, but allows properly hijacked responses to work regardless of Rack version. Followup-to: commit fdf09e562733f9509d275cb13c1c1a04e579a68a ("http_request: support rack.hijack by default") --- lib/unicorn/http_response.rb | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index cc027c5..c9c2de8 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -36,9 +36,9 @@ module Unicorn::HttpResponse when %r{\A(?:Date\z|Connection\z)}i next when "rack.hijack" - # this was an illegal key in Rack < 1.5, so it should be - # OK to silently discard it for those older versions - hijack = hijack_prepare(value) + # This should only be hit under Rack >= 1.5, as this was an illegal + # key in Rack < 1.5 + hijack = value else if value =~ /\n/ # avoiding blank, key-only cookies with /\n+/ @@ -60,14 +60,4 @@ module Unicorn::HttpResponse ensure body.respond_to?(:close) and body.close end - - # Rack 1.5.0 (protocol version 1.2) adds response hijacking support - if ((Rack::VERSION[0] << 8) | Rack::VERSION[1]) >= 0x0102 - def hijack_prepare(value) - value - end - else - def hijack_prepare(_) - end - end end -- cgit v1.2.3-24-ge0c7