about summary refs log tree commit homepage
path: root/lib/unicorn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-07-01 13:32:33 -0700
committerEric Wong <normalperson@yhbt.net>2009-07-01 13:35:27 -0700
commitec14a20474575e77a23b713ee8fcda1e71b1d018 (patch)
tree596f6dd814beffd9a7ee04ffa2000c6b6471370d /lib/unicorn.rb
parent563d03f649ef31d2aec3505cbbed1e015493b8fc (diff)
downloadunicorn-ec14a20474575e77a23b713ee8fcda1e71b1d018.tar.gz
This gives the app ability to deny clients with 417 instead of
blindly making the decision for the underlying application.  Of
course, apps must be made aware of this.
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r--lib/unicorn.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index a2893fd..281aa7d 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -444,7 +444,15 @@ module Unicorn
     # once a client is accepted, it is processed in its entirety here
     # in 3 easy steps: read request, call app, write app response
     def process_client(app, client)
-      HttpResponse.write(client, app.call(REQUEST.read(client)))
+      response = app.call(env = REQUEST.read(client))
+
+      if 100 == response.first.to_i
+        client.write(Const::EXPECT_100_RESPONSE)
+        env.delete(Const::HTTP_EXPECT)
+        response = app.call(env)
+      end
+
+      HttpResponse.write(client, response)
     # if we get any error, try to write something back to the client
     # assuming we haven't closed the socket, but don't get hung up
     # if the socket is already closed or broken.  We'll always ensure