471,852 Members | 1,103 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

Problem with RE in AbstractBasicAuthHandler


I was trying to use the HTTPBasicAuthHandler with an MS web server
requiring authentication (basic) but without success. I digged a bit
in the urllib2 module (python 2.3.4) and it turned out to be a problem
with the regular expression matching in the
AbstractBasicAuthHandler.http_error_auth_reqed() function. The
rx.match() cannot be used since it always matches from the beginning
of the string and the reply from my server had 2 more words in front
(Negotiate, NTLM, Basic realm="...").

The patch below fixes this by replacing match() with search():

================================================== ================
--- urllib2.py-orig 2004-07-20 16:10:28.000000000 +0100
+++ urllib2.py 2004-07-20 16:29:34.000000000 +0100
@@ -631,7 +631,7 @@
# XXX could be multiple headers
authreq = headers.get(authreq, None)
if authreq:
- mo = AbstractBasicAuthHandler.rx.match(authreq)
+ mo = AbstractBasicAuthHandler.rx.search(authreq)
if mo:
scheme, realm = mo.groups()
if scheme.lower() == 'basic':
================================================== ================


Jul 18 '05 #1
0 899

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by bmiras | last post: by
reply views Thread by Bruce Davis | last post: by
11 posts views Thread by Kostatus | last post: by
117 posts views Thread by Peter Olcott | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.