44
44
class TestingHTTPRequestHandler(SimpleHTTPRequestHandler):
45
"""Handles one request.
47
A TestingHTTPRequestHandler is instantiated for every request
48
received by the associated server.
46
51
def log_message(self, format, *args):
47
52
tcs = self.server.test_case_server
219
224
self.get_multiple_ranges(file, file_size, ranges)
227
def translate_path(self, path):
228
"""Translate a /-separated PATH to the local filename syntax.
230
If the server requires it, proxy the path before the usual translation
232
if self.server.test_case_server.proxy_requests:
233
# We need to act as a proxy and accept absolute urls,
234
# which SimpleHTTPRequestHandler (parent) is not
235
# ready for. So we just drop the protocol://host:port
236
# part in front of the request-url (because we know
237
# we would not forward the request to *another*
240
# So we do what SimpleHTTPRequestHandler.translate_path
241
# do beginning with python 2.4.3: abandon query
242
# parameters, scheme, host port, etc (which ensure we
243
# provide the right behaviour on all python versions).
244
path = urlparse.urlparse(path)[2]
245
# And now, we can apply *our* trick to proxy files
248
return self._translate_path(path)
250
def _translate_path(self, path):
251
return SimpleHTTPRequestHandler.translate_path(self, path)
222
253
if sys.platform == 'win32':
223
254
# On win32 you cannot access non-ascii filenames without
224
255
# decoding them into unicode first.
225
256
# However, under Linux, you can access bytestream paths
226
257
# without any problems. If this function was always active
227
258
# it would probably break tests when LANG=C was set
228
def translate_path(self, path):
259
def _translate_path(self, path):
229
260
"""Translate a /-separated PATH to the local filename syntax.
231
262
For bzr, all url paths are considered to be utf8 paths.