[ python-Bugs-1378679 ] urllib2.HTTPBasicAuthHandler fails on non-default port

SourceForge.net noreply at sourceforge.net
Mon Dec 12 13:10:41 CET 2005


Bugs item #1378679, was opened at 2005-12-12 17:50
Message generated for change (Comment added) made by gusarov
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1378679&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: Mikhail Gusarov (gusarov)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2.HTTPBasicAuthHandler fails on non-default port

Initial Comment:
HTTPBasicAuthHandler (or, more precise, 
AbstractBasicAuthHandler) does not work when non-
default port is in use: passwords added to it just not 
being passed back in answer to the 401 error code. 
Default port works fine.

I tracked the problem with it to the HTTPPasswordMgr.
find_user_password: it accepts 'authuri' and reduce it 
using reduce_uri().

AbstractBasicAuthHandler passes as 'authuri' parameter 
just hostname, in form 'myhost:myport' and this cause 
reduce_uri() to parse it as URI with schema 'myhost' 
and netloc 'myport', which is obviously wrong. Passing 
to the reduce_uri() hostname in form 'myhost' works 
fine.

I placed the the program demonstrating the bug to the 
attach: it throws HTTPError in my case. Of course 
change the host, port, user and password to the 
reflecting your setup. <uri> given should be protected 
by the basic authentication.


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

>Comment By: Mikhail Gusarov (gusarov)
Date: 2005-12-12 18:10

Message:
Logged In: YES 
user_id=501458

Problem was fixed by changing 

user, pw = self.passwd.find_user_password(realm, host)

to the

    user, pw = self.passwd.find_user_password(realm, req.
get_full_url())

in the problem function



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

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


More information about the Python-bugs-list mailing list