about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-01-22 23:52:14 +0000
committerEric Wong <normalperson@yhbt.net>2013-01-22 23:54:37 +0000
commitfedb5e50829e6dfad30ca18ea525c812eccbec70 (patch)
treef00c797fa7838218128086fa217c92d3d47ab8f1 /lib
parent705cf5fcf8ccb37deef5d2b922d6d78d34765c5b (diff)
downloadunicorn-fedb5e50829e6dfad30ca18ea525c812eccbec70.tar.gz
Once a connection is hijacked, we ignore it completely and leave
the connection at the mercy of the application.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/http_request.rb8
-rw-r--r--lib/unicorn/http_server.rb2
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 3bc64ed..3795b3b 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -106,6 +106,10 @@ class Unicorn::HttpParser
     RACK_HIJACK = "rack.hijack".freeze
     RACK_HIJACK_IO = "rack.hijack_io".freeze
 
+    def hijacked?
+      env.include?(RACK_HIJACK_IO)
+    end
+
     def hijack_setup(e, socket)
       e[RACK_HIJACK] = proc { e[RACK_HIJACK_IO] ||= socket }
     end
@@ -113,5 +117,9 @@ class Unicorn::HttpParser
     # old Rack, do nothing.
     def hijack_setup(e, _)
     end
+
+    def hijacked?
+      false
+    end
   end
 end
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index 2d8e4e1..cc0a705 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -550,11 +550,13 @@ class Unicorn::HttpServer
   # in 3 easy steps: read request, call app, write app response
   def process_client(client)
     status, headers, body = @app.call(env = @request.read(client))
+    return if @request.hijacked?
 
     if 100 == status.to_i
       client.write(expect_100_response)
       env.delete(Unicorn::Const::HTTP_EXPECT)
       status, headers, body = @app.call(env)
+      return if @request.hijacked?
     end
     @request.headers? or headers = nil
     http_response_write(client, status, headers, body,