~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-04-13 12:17:40 UTC
  • mto: (2420.1.1 bzr.http.auth)
  • mto: This revision was merged to the branch mainline in revision 2463.
  • Revision ID: v.ladeuil+lp@free.fr-20070413121740-mnwzf1656e31aenj
Catch first succesful authentification to avoid further 401
roudtrips in hhtp urllib implementation.

* bzrlib/transport/http/_urllib2_wrappers.py:
(Request.__init__): Initialize auth parameters.
(Request.extract_auth): Moved to
HttpTransport_urllib._extract_auth.
(Request.set_auth): New method.
(PasswordManager): Now that the transport handles the auth
parameters, we can use transport.base as the auth uri and work
around the python-2.4 bug.
(HTTPBasicAuthHandler.http_error_401): Capture the auth scheme
when the authentication succeeds.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib.__init__): Extract authentication at
construction time so that we don't have to do it at request build
time. urllib2 will be happier without it.
(HttpTransport_urllib._extract_auth): Moved from
_urllib2_wrappers.Request.extract_auth.
(HttpTransport_urllib._ask_password): Made private and do not
require a 'request' parameter anymore.
(HttpTransport_urllib._perform): The transport is now responsible
for handling the auth parameters and provide them to the
requests. And from there we can avoid the 401 roundtrips
yeaaaaah! (Except the first one of course to determine the auth
scheme).

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
            self._query, self._fragment) = urlparse.urlparse(self.base)
144
144
        self._qualified_proto = apparent_proto
145
145
        # range hint is handled dynamically throughout the life
146
 
        # of the object. We start by trying multi-range requests
147
 
        # and if the server returns bougs results, we retry with
148
 
        # single range requests and, finally, we forget about
149
 
        # range if the server really can't understand. Once
150
 
        # aquired, this piece of info is propogated to clones.
 
146
        # of the transport object. We start by trying multi-range
 
147
        # requests and if the server returns bogus results, we
 
148
        # retry with single range requests and, finally, we
 
149
        # forget about range if the server really can't
 
150
        # understand. Once acquired, this piece of info is
 
151
        # propagated to clones.
151
152
        if from_transport is not None:
152
153
            self._range_hint = from_transport._range_hint
153
154
        else: