mercurial/httprepo.py
changeset 4678 a814a5b11fff
parent 4633 ff7253a0d1da
child 4739 1da35d1e7ef9
equal deleted inserted replaced
4677:de8ec7e1753a 4678:a814a5b11fff
   118         def https_open(self, req):
   118         def https_open(self, req):
   119             return self.do_open(httpsconnection, req)
   119             return self.do_open(httpsconnection, req)
   120 else:
   120 else:
   121     class httphandler(basehttphandler):
   121     class httphandler(basehttphandler):
   122         pass
   122         pass
       
   123 
       
   124 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if
       
   125 # it doesn't know about the auth type requested.  This can happen if
       
   126 # somebody is using BasicAuth and types a bad password.
       
   127 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler):
       
   128     def http_error_auth_reqed(self, auth_header, host, req, headers):
       
   129         try:
       
   130             return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed(
       
   131                         self, auth_header, host, req, headers)
       
   132         except ValueError, inst:
       
   133             arg = inst.args[0]
       
   134             if arg.startswith("AbstractDigestAuthHandler doesn't know "):
       
   135                 return
       
   136             raise
   123 
   137 
   124 def zgenerator(f):
   138 def zgenerator(f):
   125     zd = zlib.decompressobj()
   139     zd = zlib.decompressobj()
   126     try:
   140     try:
   127         for chunk in util.filechunkiter(f):
   141         for chunk in util.filechunkiter(f):
   200             ui.debug(_('http auth: user %s, password %s\n') %
   214             ui.debug(_('http auth: user %s, password %s\n') %
   201                      (user, passwd and '*' * len(passwd) or 'not set'))
   215                      (user, passwd and '*' * len(passwd) or 'not set'))
   202             passmgr.add_password(None, host, user, passwd or '')
   216             passmgr.add_password(None, host, user, passwd or '')
   203 
   217 
   204         handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr),
   218         handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr),
   205                          urllib2.HTTPDigestAuthHandler(passmgr)))
   219                          httpdigestauthhandler(passmgr)))
   206         opener = urllib2.build_opener(*handlers)
   220         opener = urllib2.build_opener(*handlers)
   207 
   221 
   208         # 1.0 here is the _protocol_ version
   222         # 1.0 here is the _protocol_ version
   209         opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
   223         opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
   210         urllib2.install_opener(opener)
   224         urllib2.install_opener(opener)