diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-14 00:23:19 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-13 17:08:24 -0800 |
commit | e4256da292f9626d7dfca60e08f65651a0a9139a (patch) | |
tree | 5d90f73ce87cb5771f1f1f7bac007185028e80ea /lib/unicorn/tee_input.rb | |
parent | 1b7b4d160610dd538eee624ef8eb8c6ed301a2b5 (diff) | |
download | unicorn-e4256da292f9626d7dfca60e08f65651a0a9139a.tar.gz |
Leaving the EOFError exception as-is bad because most applications/frameworks run an application-wide exception handler to pretty-print and/or log the exception with a huge backtrace. Since there's absolutely nothing we can do in the server-side app to deal with clients prematurely shutting down, having a backtrace does not make sense. Having a backtrace can even be harmful since it creates unnecessary noise for application engineers monitoring or tracking down real bugs.
Diffstat (limited to 'lib/unicorn/tee_input.rb')
-rw-r--r-- | lib/unicorn/tee_input.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 69397c0..50ddb5b 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -135,10 +135,21 @@ 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}", [] end def finalize_input while parser.trailers(req, buf).nil? + # Don't worry about throw-ing :http_499 here on EOFError, tee() + # will catch EOFError when app is processing it, otherwise in + # initialize we never get any chance to enter the app so the + # EOFError will just get trapped by Unicorn and not the Rack app buf << socket.readpartial(Const::CHUNK_SIZE) end self.socket = nil |