urllib2, proxies and https

A

Astan Chee

Hi again,
According to
https://demo.launchpad.net/products/python/+bug/56872
or more specifically, the example of its working code:
http://librarian.demo.launchpad.net/3507227/urllib2_proxy_auth.py
I can use urllib2 via proxy to access a https site(specifically hooking
it up to libgmail).
The problem is that the proxy that is accessible to me is http/port8080
only. Is it possible to use urllib2 with this proxy to access a https
site? (im guessing no, but im sure there are ways around it).
I've tried modifying the code to point to a https site
(https://mail.google.com/mail/) without changing the http proxy and it
produces a HTTP timeout error.
Despite this, if I manually use a web browser to access these sites it
prompts me with the proxy login and lets me through. So im also puzzled
here why my browser lets this happen but urllib2 doesnt.
Thanks again for all your help.
Cheers
Astan
 
J

John J. Lee

Astan Chee said:
Hi again,
According to
https://demo.launchpad.net/products/python/+bug/56872
or more specifically, the example of its working code:
http://librarian.demo.launchpad.net/3507227/urllib2_proxy_auth.py
I can use urllib2 via proxy to access a https site(specifically
hooking it up to libgmail).
[...]

The code at that URL seems to be claiming you CAN'T do that, even with
HTTP URLs (note HTTP, not HTTPS). Hopefully (s)he is complaining
about 2.4 -- there are a bunch of bugs with this kind of thing fixed
in Python 2.5.

Re HTTPS: urllib2 does not support the CONNECT method (nor urllib, I
think), so no, you can't visit HTTPS URLS through a proxy with vanilla
urllib2. There are some hacks lying around in the cookbook and on the
Python SF tracker showing how to do it, though.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top