~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-11-10 15:09:09 UTC
  • mfrom: (2916.2.17 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071110150909-ik5254kgn930th10
Merge streamable-containers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    urlutils,
24
24
    )
25
25
from bzrlib.trace import mutter
26
 
from bzrlib.transport import register_urlparse_netloc_protocol
27
26
from bzrlib.transport.http import HttpTransportBase
28
27
# TODO: handle_response should be integrated into the _urllib2_wrappers
29
28
from bzrlib.transport.http.response import handle_response
30
29
from bzrlib.transport.http._urllib2_wrappers import (
31
30
    Opener,
32
31
    Request,
33
 
    extract_authentication_uri,
34
 
    extract_credentials,
35
32
    )
36
33
 
37
34
 
38
 
register_urlparse_netloc_protocol('http+urllib')
39
 
 
40
 
 
41
35
class HttpTransport_urllib(HttpTransportBase):
42
36
    """Python urllib transport for http and https."""
43
37
 
61
55
        path = self._combine_paths(self._path, relative)
62
56
        # urllib2 will be confused if it find authentication
63
57
        # info (user, password) in the urls. So we handle them separatly.
 
58
 
 
59
        # rhaaaa ! confused where ? confused when ? --vila 20070922
64
60
        return self._unsplit_url(self._unqualified_scheme,
65
61
                                 None, None, self._host, self._port, path)
66
62
 
75
71
            request.connection = connection
76
72
            (auth, proxy_auth) = self._get_credentials()
77
73
        else:
78
 
            # First request, intialize credentials
 
74
            # First request, intialize credentials.
 
75
            # scheme and realm will be set by the _urllib2_wrappers.AuthHandler
79
76
            user = self._user
80
77
            password = self._password
81
 
            authuri = self._remote_path('.')
82
 
            auth = {'user': user, 'password': password, 'authuri': authuri}
83
 
 
84
 
            if user and password is not None: # '' is a valid password
85
 
                # Make the (user, password) available to urllib2
86
 
                # We default to a realm of None to catch them all.
87
 
                self._opener.password_manager.add_password(None, authuri,
88
 
                                                           user, password)
89
 
            proxy_auth = {}
 
78
            auth = dict(host=self._host, port=self._port,
 
79
                        user=user, password=password,
 
80
                        protocol=self._unqualified_scheme,
 
81
                        path=self._path)
 
82
            # Proxy initialization will be done by first proxied request
 
83
            proxy_auth = dict()
90
84
        # Ensure authentication info is provided
91
85
        request.auth = auth
92
86
        request.proxy_auth = proxy_auth
110
104
                and code in (301, 302, 303, 307):
111
105
            raise errors.RedirectRequested(request.get_full_url(),
112
106
                                           request.redirected_to,
113
 
                                           is_permament=(code == 301),
 
107
                                           is_permanent=(code == 301),
114
108
                                           qual_proto=self._scheme)
115
109
 
116
110
        if request.redirected_to is not None: