This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: http auth documentation/implementation conflict
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: doko, georg.brandl, michael.foord
Priority: normal Keywords:

Created on 2005-08-13 16:49 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg26055 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2005-08-13 16:49
 [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.

msg26056 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2005-08-30 12:58
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.
msg26057 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-19 00:21
Logged In: YES 
user_id=1188172

The given URI is split via urlparse, so adding a protocol
wouldn't matter. The problem must have been a different one,
perhaps a misspelling.

Closing as Invalid.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42277
2005-08-13 16:49:31dokocreate