[ python-Bugs-1258485 ] http auth documentation/implementation conflict

SourceForge.net noreply at sourceforge.net
Tue Aug 30 14:58:37 CEST 2005


Bugs item #1258485, was opened at 2005-08-13 16:49
Message generated for change (Comment added) made by mjfoord
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1258485&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: http auth documentation/implementation conflict

Initial Comment:
 [forwarded from http://bugs.debian.org/304925]

Bug reporter writes:

I was trying to implement a basic HTTP client using
HTTP basic
authorization. The current preferred method of doing
this is by using
urllib2 HTTPPasswordMgr. 

A simple test snippet to try this:

pwmgr=urllib2.HTTPPasswordMgrWithDefaultRealm()
pwmgr.add_password(None, url, username, password)
handler=urllib2.HTTPBasicAuthHandler(pwmgr)
opener=urllib2.build_opener(handler)
urllib2.install_opener(opener)
u=urllib2.urlopen(url)

This did not work. Modifying the second line to:

pwmgr.add_password(None, urlparse.urlparse(url)[1],
username, password)

fixed things, which shows a problem in the
documentation: instead of
a URI or sequence of URIs the add_password method takes
a hostname. 

The documented behaviour would be better since it
allows for multiple
passwords per host, although in reality those will use
different realms.
So I suggest not changing the code in order to not
break existing
application but fixing the documentation instead.



----------------------------------------------------------------------

Comment By: Mike Foord (mjfoord)
Date: 2005-08-30 12:58

Message:
Logged In: YES 
user_id=1123892

I think it likely that the OP was using a URL that *included* 
the protocol - (i.e. "http://www.somedomain.com/path") 
instead of just "www.somedomain.com/path".

It is a problem that also bit me - and could *definitely* do with 
a mention in the docs.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1258485&group_id=5470


More information about the Python-bugs-list mailing list