19
19
There are separate implementation modules for each http client implementation.
22
from collections import deque
23
from cStringIO import StringIO
24
from collections import deque
25
from cStringIO import StringIO
29
31
from warnings import warn
31
33
from bzrlib.transport import Transport, register_transport, Server
32
34
from bzrlib.errors import (TransportNotPossible, NoSuchFile,
33
TransportError, ConnectionError)
34
from bzrlib.errors import BzrError, BzrCheckError
35
TransportError, ConnectionError, InvalidURL)
35
36
from bzrlib.branch import Branch
36
37
from bzrlib.trace import mutter
37
38
# TODO: load these only when running http tests
113
114
implementation qualifier.
115
116
assert isinstance(relpath, basestring)
117
if isinstance(relpath, unicode):
118
raise InvalidURL(relpath, 'paths must not be unicode.')
116
119
if isinstance(relpath, basestring):
117
120
relpath_parts = relpath.split('/')
397
400
method = getattr(self, mname)
403
if sys.platform == 'win32':
404
# On win32 you cannot access non-ascii filenames without
405
# decoding them into unicode first.
406
# However, under Linux, you can access bytestream paths
407
# without any problems. If this function was always active
408
# it would probably break tests when LANG=C was set
409
def translate_path(self, path):
410
"""Translate a /-separated PATH to the local filename syntax.
412
For bzr, all url paths are considered to be utf8 paths.
413
On Linux, you can access these paths directly over the bytestream
414
request, but on win32, you must decode them, and access them
417
# abandon query parameters
418
path = urlparse.urlparse(path)[2]
419
path = posixpath.normpath(urllib.unquote(path))
420
path = path.decode('utf-8')
421
words = path.split('/')
422
words = filter(None, words)
425
drive, word = os.path.splitdrive(word)
426
head, word = os.path.split(word)
427
if word in (os.curdir, os.pardir): continue
428
path = os.path.join(path, word)
401
432
class TestingHTTPServer(BaseHTTPServer.HTTPServer):
402
433
def __init__(self, server_address, RequestHandlerClass, test_case):