[Python-bugs-list] [Bug #125217] urllib2.py and proxies (Python 2.0)
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 11 Dec 2000 12:48:43 -0800
Bug #125217, was updated on 2000-Dec-09 22:12
Here is a current snapshot of the bug.
Project: Python
Category: Library
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: tww-china
Assigned to : jhylton
Summary: urllib2.py and proxies (Python 2.0)
Details: Consider the following program:
import os, sys, urllib2
from urllib2 import urlopen
os.environ['http_proxy'] = 'http://[HOST]:5865'
authinfo = urllib2.HTTPBasicAuthHandler ()
authinfo.add_password ('[REALM]', 'http://[URL]', '[login]',
'[password]')
opener = urllib2.build_opener (authinfo)
urllib2.install_opener (opener)
url = urlopen ('http://[URL]/')
print url.info ()
url.close ()
Urllib2.py does not work if we wish to do BASIC authentication to a URL through a proxy. Chances are it also will not work if the proxy requires BASIC authentication too and the URL requires BASIC authentication. Here's the error I receive (Solaris 7/SPARC but platform does not matter):
File "/tmp/a.py", line 15, in ?
url = urlopen ('http://updates.thewrittenword.com/')
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 137, in urlopen
return _opener.open(url, data)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 325, in open
'_open', req)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 304, in _call_chain
result = func(*args)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 764, in http_open
return self.parent.error('http', req, fp, code, msg, hdrs)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 351, in error
return self._call_chain(*args)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 304, in _call_chain
result = func(*args)
File "/opt/TWWfsw/pkgutils12/lib/python20/lib/python2.0/urllib2.py",
line 430, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Authorization Required
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=125217&group_id=5470