about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-15 12:09:23 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-15 12:09:32 -0800
commita80ba923659a4287f05a8c69fe2c5ad8b65d28f7 (patch)
tree17f6aa4fef65008e03d5c0caabbddfecd755eb0b /lib
parent6d7e11482a484b50215701993408057b80c82bbe (diff)
downloadunicorn-a80ba923659a4287f05a8c69fe2c5ad8b65d28f7.tar.gz
First move it to a separate method, this allows subclasses to
reuse our error handler.  Additionally, capture HttpParserError
as well since backtraces are worthless when a client sends us
a bad request, too.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/tee_input.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb
index 01717ce..18ce44b 100644
--- a/lib/unicorn/tee_input.rb
+++ b/lib/unicorn/tee_input.rb
@@ -123,6 +123,21 @@ module Unicorn
 
   private
 
+    def client_error(e)
+      case e
+      when EOFError
+        # in case client only did a premature shutdown(SHUT_WR)
+        # we do support clients that shutdown(SHUT_WR) after the
+        # _entire_ request has been sent, and those will not have
+        # raised EOFError on us.
+        socket.close if socket
+        raise ClientShutdown, "bytes_read=#{@tmp.size}", []
+      when HttpParserError
+        e.set_backtrace([])
+        raise e
+      end
+    end
+
     # tees off a +length+ chunk of data from the input into the IO
     # backing store as well as returning it.  +dst+ must be specified.
     # returns nil if reading from the input returns nil
@@ -135,13 +150,8 @@ module Unicorn
         end
       end
       finalize_input
-      rescue EOFError
-        # in case client only did a premature shutdown(SHUT_WR)
-        # we do support clients that shutdown(SHUT_WR) after the
-        # _entire_ request has been sent, and those will not have
-        # raised EOFError on us.
-        socket.close if socket
-        raise ClientShutdown, "bytes_read=#{@tmp.size}", []
+      rescue => e
+        client_error(e)
     end
 
     def finalize_input