about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-05-19 19:57:44 +0000
committerEric Wong <e@80x24.org>2015-06-01 19:00:08 +0000
commit090829a95ba4e3c6fe4562c9feb8fde5382a44f4 (patch)
tree05766c1345e8731285b645ab88da2735c7c251b1
parent32fefc5742d1646d63a119b281baefcac551dfec (diff)
downloadunicorn-090829a95ba4e3c6fe4562c9feb8fde5382a44f4.tar.gz
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")
-rw-r--r--lib/unicorn/http_response.rb16
1 files 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