[PATCH 2 of 4] http: add passwordmgr.setrequest hook
Markus Zapke-Gründemann
markuszapke at gmx.net
Fri Sep 14 09:46:49 CDT 2012
# HG changeset patch
# User Markus Zapke-Gründemann <markus at keimlink.de>
# Date 1347617250 -7200
# Node ID 25364f6396dc3858d51782516a4ee3de20aca9e9
# Parent edb5487b1bb7e60aa46d77243487eee1a27223b9
http: add passwordmgr.setrequest hook
The passwordmgr.setrequest hook can be used by password managers to get
access to the request object. The keyring 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
@@ -353,6 +353,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)
@@ -401,6 +405,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.
@@ -429,6 +437,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