[ python-Bugs-944396 ] urllib2 doesn't handle username/password in url

SourceForge.net noreply at sourceforge.net
Wed May 5 17:22:24 EDT 2004


Bugs item #944396, was opened at 2004-04-29 13:04
Message generated for change (Comment added) made by sjoerd
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=944396&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2 doesn't handle username/password in url

Initial Comment:
>>> urllib2.urlopen('http://username:password@server')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\PYTHON23\lib\urllib2.py", line 129, in urlopen
    return _opener.open(url, data)
  File "C:\PYTHON23\lib\urllib2.py", line 326, in open
    '_open', req)
  File "C:\PYTHON23\lib\urllib2.py", line 306, in
_call_chain
    result = func(*args)
  File "C:\PYTHON23\lib\urllib2.py", line 901, in http_open
    return self.do_open(httplib.HTTP, req)
  File "C:\PYTHON23\lib\urllib2.py", line 860, in do_open
    h = http_class(host) # will parse host:port
  File "C:\Python23\lib\httplib.py", line 1009, in __init__
    self._setup(self._connection_class(host, port, strict))
  File "C:\Python23\lib\httplib.py", line 507, in __init__
    self._set_hostport(host, port)
  File "C:\Python23\lib\httplib.py", line 518, in
_set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: 'password at server'

cheers,

Chris

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

>Comment By: Sjoerd Mullender (sjoerd)
Date: 2004-05-05 23:22

Message:
Logged In: YES 
user_id=43607

I don't know (nor care) about RFC 1738, but it's successor
RFC 2396 *does* mention <userinfo>@<host>:<port> as a
possible "server".  See section 3.2.2.  I admit, it also
says that it is not recommended, but it does specifically
allow username + password in the URI.

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

Comment By: Chris Withers (fresh)
Date: 2004-05-05 23:01

Message:
Logged In: YES 
user_id=24723

However, given that the original urllib supported this, it
is suprising that urllib2 doesn't.

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

Comment By: Andrew Langmead (langmead)
Date: 2004-05-05 22:34

Message:
Logged In: YES 
user_id=119306

Although allowing a username and password in the URL is a 
common client extension, it is not part of the standard <http://
rfc.net/rfc1738.html#s3.3.>

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

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



More information about the Python-bugs-list mailing list