~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Better handling of passwords (user should be queried only once).

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib.ask_password): Avoid requesting password
from user by querying the password manager for already typed
password.

* bzrlib/transport/http/_urllib2_wrappers.py:
(Response, Response.begin): Makes the body ignored responses
extensible by daughter classes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    than using a custom object.
59
59
    """
60
60
 
 
61
    # Some responses have bodies in which we have no interest
 
62
    _body_ignored_responses = [301,302, 303, 307, 401,]
 
63
 
61
64
    def __init__(self, *args, **kwargs):
62
65
        httplib.HTTPResponse.__init__(self, *args, **kwargs)
63
66
 
70
73
        try to workaround that.
71
74
        """
72
75
        httplib.HTTPResponse.begin(self)
73
 
        if self.status in (999,
74
 
                           301,
75
 
                           302, 303, 307,
76
 
                           401, ):
 
76
        if self.status in self._body_ignored_responses:
77
77
            body = self.fp.read(self.length)
78
78
            #print "Consumed body: [%s]" % body
79
79
            self.close()