[PATCH 2 of 3] http: add passwordmgr.setrequest hook
Markus Zapke-Gründemann
markuszapke at gmx.net
Fri Aug 24 04:40:18 CDT 2012
# HG changeset patch
# User Markus Zapke-Gründemann <markus at keimlink.de>
# Date 1345799209 -7200
# Node ID eb40ccf52cf171cc111d64418fbe81b7ecf42143
# Parent 16bb1c7b869f50fe09a62062fe0b7b5e0679b6ba
http: add passwordmgr.setrequest hook
The passwordmgr.setrequest hook can be used by password managers to get
access to the request object. The hgkeyring extension uses this hook.
diff --git a/mercurial/httpconnection.py b/mercurial/httpconnection.py
--- a/mercurial/httpconnection.py
+++ b/mercurial/httpconnection.py
@@ -239,6 +239,10 @@ class http2handler(urllib2.HTTPHandler,
# req.get_full_url() does not contain credentials and we may
# need them to match the certificates.
url = req.get_full_url()
+ try:
+ self.pwmgr.setrequest(req)
+ except AttributeError:
+ pass
user, password = self.pwmgr.find_stored_password(url)
res = readauthforuri(self.ui, url, user)
if res:
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -352,6 +352,10 @@ if has_https:
def https_open(self, req):
# req.get_full_url() does not contain credentials and we may
# need them to match the certificates.
+ try:
+ self.pwmgr.setrequest(req)
+ except AttributeError:
+ pass
url = req.get_full_url()
user, password = self.pwmgr.find_stored_password(url)
res = httpconnectionmod.readauthforuri(self.ui, url, user)
@@ -400,6 +404,10 @@ class httpdigestauthhandler(urllib2.HTTP
if req is not self.retried_req:
self.retried_req = req
self.retried = 0
+ try:
+ self.passwd.setrequest(req)
+ except AttributeError:
+ pass
# In python < 2.5 AbstractDigestAuthHandler raises a ValueError if
# it doesn't know about the auth type requested. This can happen if
# somebody is using BasicAuth and types a bad password.
@@ -428,6 +436,10 @@ class httpbasicauthhandler(urllib2.HTTPB
if req is not self.retried_req:
self.retried_req = req
self.retried = 0
+ try:
+ self.passwd.setrequest(req)
+ except AttributeError:
+ pass
return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
self, auth_header, host, req, headers)
More information about the Mercurial-devel
mailing list