60
60
def handle_one_request(self):
61
61
"""Handle a single HTTP request.
63
You normally don't need to override this method; see the class
64
__doc__ string for information on how to handle specific HTTP
65
commands such as GET and POST.
63
We catch all socket errors occurring when the client close the
64
connection early to avoid polluting the test results.
68
for i in xrange(1,11): # Don't try more than 10 times
70
self.raw_requestline = self.rfile.readline()
71
except socket.error, e:
72
if e.args[0] in (errno.EAGAIN, errno.EWOULDBLOCK):
73
# omitted for now because some tests look at the log of
74
# the server and expect to see no errors. see recent
75
# email thread. -- mbp 20051021.
76
## self.log_message('EAGAIN (%d) while reading from raw_requestline' % i)
67
SimpleHTTPRequestHandler.handle_one_request(self)
68
except socket.error, e:
70
and e.args[0] in (errno.EPIPE, errno.ECONNRESET,
71
errno.ECONNABORTED,)):
72
self.close_connection = 1
82
if not self.raw_requestline:
83
self.close_connection = 1
85
if not self.parse_request(): # An error code has been sent, just exit
87
mname = 'do_' + self.command
88
if getattr(self, mname, None) is None:
89
self.send_error(501, "Unsupported method (%r)" % self.command)
91
method = getattr(self, mname)
94
77
_range_regexp = re.compile(r'^(?P<start>\d+)-(?P<end>\d+)$')
95
78
_tail_regexp = re.compile(r'^-(?P<tail>\d+)$')
291
274
# the tests cases.
292
275
self.test_case_server = test_case_server
277
def server_close(self):
278
"""Called to clean-up the server.
280
Since the server may be in a blocking read, we shutdown the socket
283
self.socket.shutdown(socket.SHUT_RDWR)
284
BaseHTTPServer.HTTPServer.server_close(self)
295
287
class HttpServer(Server):
296
288
"""A test server for http transports.