summaryrefslogtreecommitdiffstats
path: root/Lib/urllib2.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-05-29 20:52:54 (GMT)
committerGeorg Brandl <georg@python.org>2006-05-29 20:52:54 (GMT)
commit261e251df8ed5b588ecb2b9f722596c085c8c244 (patch)
treef60e3e576db37e8fc7b340159e7f3749be1e2ad1 /Lib/urllib2.py
parent08490146df70ef8c98f9c828ea861c661761b09e (diff)
downloadcpython-261e251df8ed5b588ecb2b9f722596c085c8c244.zip
cpython-261e251df8ed5b588ecb2b9f722596c085c8c244.tar.gz
cpython-261e251df8ed5b588ecb2b9f722596c085c8c244.tar.bz2
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r--Lib/urllib2.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index b2ff04f..227311c 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -297,6 +297,10 @@ class OpenerDirector:
def add_handler(self, handler):
added = False
for meth in dir(handler):
+ if meth in ["redirect_request", "do_open", "proxy_open"]:
+ # oops, coincidental match
+ continue
+
i = meth.find("_")
protocol = meth[:i]
condition = meth[i+1:]
@@ -768,6 +772,10 @@ class AbstractBasicAuthHandler:
# www-authenticate header. should probably be a lot more careful
# in parsing them to extract multiple alternatives
+ # XXX could pre-emptively send auth info already accepted (RFC 2617,
+ # end of section 2, and section 1.2 immediately after "credentials"
+ # production).
+
def __init__(self, password_mgr=None):
if password_mgr is None:
password_mgr = HTTPPasswordMgr()
@@ -977,6 +985,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
"""
auth_header = 'Authorization'
+ handler_order = 490 # before Basic auth
def http_error_401(self, req, fp, code, msg, headers):
host = urlparse.urlparse(req.get_full_url())[1]
@@ -989,6 +998,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
auth_header = 'Proxy-Authorization'
+ handler_order = 490 # before Basic auth
def http_error_407(self, req, fp, code, msg, headers):
host = req.get_host()