Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > urllib and urllib2, with proxies

Thread Tools

urllib and urllib2, with proxies
Posts: n/a
hello all,

I just maybe hit a bug in both urllib and urllib2, actually urllib
doesn't support proxy authentication, and if you setup the http_proxy
env var to http_proxy=http://userasswd@hostort/ and
https_proxy=$http_proxy i get a traceback :

Traceback (most recent call last):
File "", line 2, in ?
File "/usr/lib/python2.4/", line 82, in urlopen
File "/usr/lib/python2.4/", line 190, in open
return getattr(self, name)(url)
File "/usr/lib/python2.4/", line 313, in open_http
File "/usr/lib/python2.4/", line 798, in endheaders
File "/usr/lib/python2.4/", line 679, in _send_output
File "/usr/lib/python2.4/", line 646, in send
File "/usr/lib/python2.4/", line 614, in connect
IOError: [Errno socket error] (-2, 'Name or service not known')

now with urllib2, it goes beyond that and connect and authenticate to
the proxy, however, instead of using CONNECT with https, it simply does
a GET, which result in a error 501 with a squid proxy:

Traceback (most recent call last):
File "", line 2, in ?
File "/usr/lib/python2.4/", line 130, in urlopen
return, data)
File "/usr/lib/python2.4/", line 358, in open
response = self._open(req, data)
File "/usr/lib/python2.4/", line 376, in _open
'_open', req)
File "/usr/lib/python2.4/", line 337, in _call_chain
result = func(*args)
File "/usr/lib/python2.4/", line 573, in <lambda>
lambda r, proxy=url, type=type, meth=self.proxy_open: \
File "/usr/lib/python2.4/", line 597, in proxy_open
File "/usr/lib/python2.4/", line 364, in open
response = meth(req, response)
File "/usr/lib/python2.4/", line 471, in http_response
response = self.parent.error(
File "/usr/lib/python2.4/", line 402, in error
return self._call_chain(*args)
File "/usr/lib/python2.4/", line 337, in _call_chain
result = func(*args)
File "/usr/lib/python2.4/", line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 501: Not Implemented

this is with python-2.4.3

thank you for your help

Ali Sabil

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
2to3 urllib.URLopener -> urllib.request.URLopener Chris McDonald Python 0 11-01-2010 11:23 AM
Asynchronous urllib (urllib+asyncore)? Jonathan Gardner Python 1 02-27-2008 12:51 AM
css and csm for load balancing (firewalls and proxies) Cisco 0 05-03-2006 08:28 PM
Java and proxies Paul Taylor Java 0 06-28-2005 04:29 PM
HttpURLConnection, Proxies and Authentication Roger Java 3 07-13-2004 01:53 PM