diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-07-01 10:01:31 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-07-01 10:01:31 (GMT) |
commit | 985fc6a3041e992448827fd2b496cc5b3f344b28 (patch) | |
tree | 776a30cdbfe53180711389c95fa550d77c2e65a2 /Lib/http | |
parent | fae45ed87441f54b10607081e0455acd9e5ad630 (diff) | |
download | cpython-985fc6a3041e992448827fd2b496cc5b3f344b28.zip cpython-985fc6a3041e992448827fd2b496cc5b3f344b28.tar.gz cpython-985fc6a3041e992448827fd2b496cc5b3f344b28.tar.bz2 |
http://bugs.python.org/issue6267
porting revision 73638 to py3k
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/server.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 2163e74..c9cfe9b 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -332,18 +332,26 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): commands such as GET and POST. """ - self.raw_requestline = self.rfile.readline() - if not self.raw_requestline: + try: + self.raw_requestline = self.rfile.readline() + if not self.raw_requestline: + self.close_connection = 1 + return + if not self.parse_request(): + # An error code has been sent, just exit + return + mname = 'do_' + self.command + if not hasattr(self, mname): + self.send_error(501, "Unsupported method (%r)" % self.command) + return + method = getattr(self, mname) + method() + self.wfile.flush() #actually send the response if not already done. + except socket.timeout as e: + #a read or a write timed out. Discard this connection + self.log_error("Request timed out: %r", e) self.close_connection = 1 return - if not self.parse_request(): # An error code has been sent, just exit - return - mname = 'do_' + self.command - if not hasattr(self, mname): - self.send_error(501, "Unsupported method (%r)" % self.command) - return - method = getattr(self, mname) - method() def handle(self): """Handle multiple requests if necessary.""" |