[ python-Bugs-1075427 ] urllib2.HTTPBasicAuthHandler problem with [HOST]:[PORT]

SourceForge.net noreply at sourceforge.net
Mon Feb 20 22:02:52 CET 2006


Bugs item #1075427, was opened at 2004-11-29 18:06
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1075427&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: Extension Modules
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: O-Zone (o-zone2004)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2.HTTPBasicAuthHandler problem with [HOST]:[PORT]

Initial Comment:
I've encountered problems authenticating to an host
with this piece of code:

       passman =
urllib2.HTTPPasswordMgrWithDefaultRealm()      
        passman.add_password(None, theurl, username,
password)      
        authhandler =
urllib2.HTTPBasicAuthHandler(passman)                 
        opener = urllib2.build_opener(authhandler)    
                             
        urllib2.install_opener(opener)
        req = urllib2.Request(theurl)
        try:
            handle = urllib2.urlopen(req)

if i specify an URL like: http://[MyHostIP]:[Port] auth
helper never authorize me on the host. 

It work perfectly if i don't specify ANY port in the URL.

Regards, Michele "O-Zone" Pinassi

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

>Comment By: Georg Brandl (gbrandl)
Date: 2006-02-20 21:02

Message:
Logged In: YES 
user_id=849994

Closing, as the patch #974757 was committed.

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

Comment By: MM Zeeman (mmzeeman)
Date: 2004-12-09 10:33

Message:
Logged In: YES 
user_id=350634

This is actually the same problem as reported in bug 974757,
which has a 
patch attached to it. 

The problem is that with basic authentication only the 
hostname + portnumber is passed to find_user_password. This
method 
works if there is no port number when a netloc is used. 

It looks like the answer from reduce_uri is wrong when port
numbers are used.



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

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


More information about the Python-bugs-list mailing list