urllib2 : https and proxy

cp.finances.gouv at gmail.com cp.finances.gouv at gmail.com
Thu Jun 28 05:07:43 EDT 2007


Hello all,

I'm facing a strange behavior of urllib2 trying to access gmail
account behind a proxy (Squid).

The following works perfectly :

wget  --save-cookies cookies --keep-session-cookies --post-
data="Email=externe.finances.gouv at gmail.com&Passwd=cpfinances" --no-
check-certificate  -O - https://www.google.com/accounts/ServiceLoginBoxAuth


While the following urllib2 code fail with an error 501 :

In [18]: import urllib2

In [19]: r=urllib2.urlopen("https://www.google.com/accounts/
ServiceLoginBoxAuth",
 
"Email=externe.finances.gouv at gmail.com&Passwd=cpfinances")
---------------------------------------------------------------------------
urllib2.HTTPError                                 Traceback (most
recent call last)

/home/maric/<ipython console>

/home/maric/urllib2.py in urlopen(url, data)
    128     if _opener is None:
    129         _opener = build_opener()
--> 130     return _opener.open(url, data)

...

/home/maric/urllib2.py in http_error_default(self, req, fp, code, msg,
hdrs)
    478 class HTTPDefaultErrorHandler(BaseHandler):
    479     def http_error_default(self, req, fp, code, msg, hdrs):
--> 480         raise HTTPError(req.get_full_url(), code, msg, hdrs,
fp)
    481
    482 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 501: Not Implemented


I understood it's a response from the proxy about incompatible
protocols and queries but this seem rather strange in this case. Could
there be a bug in the ProxyHandler class ? Any idea about what could
cause this error on the proxy ?




More information about the Python-list mailing list