~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/__init__.py

  • Committer: Robey Pointer
  • Date: 2006-07-01 19:03:33 UTC
  • mfrom: (1829 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: robey@lag.net-20060701190333-f58465aec4bd3412
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
There are separate implementation modules for each http client implementation.
20
20
"""
21
21
 
 
22
from collections import deque
 
23
from cStringIO import StringIO
22
24
import errno
23
25
import os
24
 
from collections import deque
25
 
from cStringIO import StringIO
 
26
import posixpath
26
27
import re
 
28
import sys
27
29
import urlparse
28
30
import urllib
29
31
from warnings import warn
398
400
        method = getattr(self, mname)
399
401
        method()
400
402
 
 
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.
 
411
 
 
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
 
415
            as Unicode files.
 
416
            """
 
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)
 
423
            path = os.getcwdu()
 
424
            for word in 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)
 
429
            return path
 
430
 
401
431
 
402
432
class TestingHTTPServer(BaseHTTPServer.HTTPServer):
403
433
    def __init__(self, server_address, RequestHandlerClass, test_case):