284
285
return self._translate_path(path)
286
287
def _translate_path(self, path):
287
return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(
290
if sys.platform == 'win32':
291
# On win32 you cannot access non-ascii filenames without
292
# decoding them into unicode first.
293
# However, under Linux, you can access bytestream paths
294
# without any problems. If this function was always active
295
# it would probably break tests when LANG=C was set
296
def _translate_path(self, path):
297
"""Translate a /-separated PATH to the local filename syntax.
299
For bzr, all url paths are considered to be utf8 paths.
300
On Linux, you can access these paths directly over the bytestream
301
request, but on win32, you must decode them, and access them
304
# abandon query parameters
305
path = urlparse.urlparse(path)[2]
306
path = posixpath.normpath(urllib.unquote(path))
307
path = path.decode('utf-8')
308
words = path.split('/')
309
words = filter(None, words)
288
"""Translate a /-separated PATH to the local filename syntax.
290
Note that we're translating http URLs here, not file URLs.
291
The URL root location is the server's startup directory.
292
Components that mean special things to the local file system
293
(e.g. drive or directory names) are ignored. (XXX They should
294
probably be diagnosed.)
296
Override from python standard library to stop it calling os.getcwd()
298
# abandon query parameters
299
path = urlparse.urlparse(path)[2]
300
path = posixpath.normpath(urllib.unquote(path))
301
path = path.decode('utf-8')
302
words = path.split('/')
303
words = filter(None, words)
305
for num, word in enumerate(words):
312
307
drive, word = os.path.splitdrive(word)
313
head, word = os.path.split(word)
314
if word in (os.curdir, os.pardir): continue
315
path = os.path.join(path, word)
308
head, word = os.path.split(word)
309
if word in (os.curdir, os.pardir): continue
310
path = os.path.join(path, word)
319
314
class TestingHTTPServerMixin: