|
@@ -315,6 +315,7 @@ class HTTPRequest(object):
|
|
|
self.wsgi_app = wsgi_app
|
|
self.wsgi_app = wsgi_app
|
|
|
|
|
|
|
|
self.ready = False
|
|
self.ready = False
|
|
|
|
|
+ self.started_request = False
|
|
|
self.started_response = False
|
|
self.started_response = False
|
|
|
self.status = ""
|
|
self.status = ""
|
|
|
self.outheaders = []
|
|
self.outheaders = []
|
|
@@ -342,6 +343,9 @@ class HTTPRequest(object):
|
|
|
# (although your TCP stack might suffer for it: cf Apache's history
|
|
# (although your TCP stack might suffer for it: cf Apache's history
|
|
|
# with FIN_WAIT_2).
|
|
# with FIN_WAIT_2).
|
|
|
request_line = self.rfile.readline()
|
|
request_line = self.rfile.readline()
|
|
|
|
|
+ # Set started_request to True so communicate() knows to send 408
|
|
|
|
|
+ # from here on out.
|
|
|
|
|
+ self.started_request = True
|
|
|
if not request_line:
|
|
if not request_line:
|
|
|
# Force self.ready = False so the connection will close.
|
|
# Force self.ready = False so the connection will close.
|
|
|
self.ready = False
|
|
self.ready = False
|
|
@@ -1199,6 +1203,9 @@ class HTTPConnection(object):
|
|
|
# This order of operations should guarantee correct pipelining.
|
|
# This order of operations should guarantee correct pipelining.
|
|
|
req.parse_request()
|
|
req.parse_request()
|
|
|
if not req.ready:
|
|
if not req.ready:
|
|
|
|
|
+ # Something went wrong in the parsing (and the server has
|
|
|
|
|
+ # probably already made a simple_response). Return and
|
|
|
|
|
+ # let the conn close.
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
req.respond()
|
|
req.respond()
|
|
@@ -1208,7 +1215,10 @@ class HTTPConnection(object):
|
|
|
except socket.error, e:
|
|
except socket.error, e:
|
|
|
errnum = e.args[0]
|
|
errnum = e.args[0]
|
|
|
if errnum == 'timed out':
|
|
if errnum == 'timed out':
|
|
|
- if req and not req.sent_headers:
|
|
|
|
|
|
|
+ # Don't send a 408 if there is no outstanding request; only
|
|
|
|
|
+ # if we're in the middle of a request.
|
|
|
|
|
+ # See http://www.cherrypy.org/ticket/853
|
|
|
|
|
+ if req and req.started_request and not req.sent_headers:
|
|
|
req.simple_response("408 Request Timeout")
|
|
req.simple_response("408 Request Timeout")
|
|
|
elif errnum not in socket_errors_to_ignore:
|
|
elif errnum not in socket_errors_to_ignore:
|
|
|
if req and not req.sent_headers:
|
|
if req and not req.sent_headers:
|