Permalink
Browse files

Rescue all types of errors when processing request

[#62 state:resolved]
  • Loading branch information...
macournoyer committed Apr 19, 2008
1 parent 79f2a32 commit a9acdec985583b0a9dd539417634b2c0eaee3b40
Showing with 14 additions and 3 deletions.
  1. +1 −0 CHANGELOG
  2. +3 −3 lib/thin/connection.rb
  3. +10 −0 spec/connection_spec.rb
View
@@ -1,4 +1,5 @@
== 0.8.1 Rebel Porpoise release
+ * [bug] Rescue all types of errors when processing request, fixes #62
* [bug] Use Swiftiply backend when -y option is specified, fixes #63 and #64
* Allow passing port as a string in Server.new
* Define deferred?(env) in your Rack application to set if a request is handled in a
View
@@ -57,7 +57,7 @@ def pre_process
# Process the request calling the Rack adapter
@app.call(@request.env)
- rescue
+ rescue Object
handle_error
terminate_request
nil # Signal to post_process that the request could not be processed
@@ -80,7 +80,7 @@ def post_process(result)
# If no more request on that same connection, we close it.
close_connection_after_writing unless persistent?
- rescue
+ rescue Object
handle_error
ensure
terminate_request
@@ -133,7 +133,7 @@ def threaded?
# IP Address of the remote client.
def remote_address
@request.forwarded_for || socket_address
- rescue
+ rescue Object
log_error
nil
end
View
@@ -30,6 +30,16 @@
@connection.process
end
+ it "should rescue error in process" do
+ @connection.app.should_receive(:call).and_raise(StandardError)
+ @connection.process
+ end
+
+ it "should rescue Timeout error in process" do
+ @connection.app.should_receive(:call).and_raise(Timeout::Error.new("timeout error not rescued"))
+ @connection.process
+ end
+
it "should return HTTP_X_FORWARDED_FOR as remote_address" do
@connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
@connection.remote_address.should == '1.2.3.4'

0 comments on commit a9acdec

Please sign in to comment.