64
64
connection early to avoid polluting the test results.
67
self._handle_one_request()
67
SimpleHTTPRequestHandler.handle_one_request(self)
68
68
except socket.error, e:
69
69
if (len(e.args) > 0
70
70
and e.args[0] in (errno.EPIPE, errno.ECONNRESET,
77
def _handle_one_request(self):
79
Request handling as defined in the base class.
81
You normally don't need to override this method; see the class
82
__doc__ string for information on how to handle specific HTTP
83
commands such as GET and POST.
85
On some platforms, notably OS X, a lot of EAGAIN (resource temporary
86
unavailable) occur. We retry silently at most 10 times.
88
for i in xrange(1,11): # Don't try more than 10 times
90
self.raw_requestline = self.rfile.readline()
91
except socket.error, e:
92
if e.args[0] in (errno.EAGAIN, errno.EWOULDBLOCK):
93
# omitted for now because some tests look at the log of
94
# the server and expect to see no errors. see recent
95
# email thread. -- mbp 20051021.
96
## self.log_message('EAGAIN (%d) while reading from raw_requestline' % i)
102
if not self.raw_requestline:
103
self.close_connection = 1
105
if not self.parse_request(): # An error code has been sent, just exit
107
mname = 'do_' + self.command
108
if getattr(self, mname, None) is None:
109
self.send_error(501, "Unsupported method (%r)" % self.command)
111
method = getattr(self, mname)
114
77
_range_regexp = re.compile(r'^(?P<start>\d+)-(?P<end>\d+)$')
115
78
_tail_regexp = re.compile(r'^-(?P<tail>\d+)$')
311
274
# the tests cases.
312
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)
315
287
class HttpServer(Server):
316
288
"""A test server for http transports.
346
318
self._http_base_url = '%s://%s:%s/' % (self._url_protocol,
349
httpd.socket.settimeout(0.1)
350
321
self._http_starting.release()
352
323
while self._http_running: