kennethreitz/requests — pull request #478 by foxx (2012-03-09 22:41:37+00:00)
Title: SSL Proxy and SOCKS proxy support now done!

Hi all,

I've now managed to add proper SOCKS proxy and HTTPS/SSL proxy support (took me about 6 hours, but was well worth the effort)

* SOCKS proxy support is done via a slightly modified SocksIpy.
* All unit tests seem to pass fine (have included tests/test_proxies.py as it's own file, as the test will only pass if you have the necessary proxy servers running - obv.)
* proxiesDict should be backwards compatible (have tested it with multiple values) - now accepts 'socks4://' and 'socks5'://
* HTTPS/SSL proxy support uses the _tunnel() method exposed from httplib
* HTTPS/SSL proxy support forcibly disables SSL certificate validation
* Has been tested extensively against 'Burp Proxy' and 'dante-server'

This code is going to be used extensively by one of our clients, so if we find any problems I'll let you know.

Hope this helps!

Cal

-------

test_requests.py before modifications:
FAILED (failures=1, errors=14)

test_requests.py after modifications:
FAILED (failures=1, errors=14)

Here is the result of the test_proxies.py (slightly trimmed):

HTTPS via SOCKS5
------------------------------------------------------------

Your IP address is
173.255.251.42

HTTP via SOCKS5
------------------------------------------------------------

Your IP address is
173.255.251.42

HTTPS via HTTP Proxy
------------------------------------------------------------

Your IP address is
89.238.182.140

HTTP via HTTP Proxy
------------------------------------------------------------

Your IP address is
89.238.182.140

HTTPS via no proxy
------------------------------------------------------------

Your IP address is
82.30.159.182

HTTP via no proxy
------------------------------------------------------------

Your IP address is
82.30.159.182