kennethreitz/requests — Issue #319: Timeout when using authenticated proxy for https request
Author: j0hnsmith
Created: 2011-12-26 07:14:10+00:00
State: open

I get a timeout when I run this

import requests

proxies = {
'https': 'https://username:password@ip:port',
}
resp = requests.get('https://www.google.com/', proxies=proxies)
print resp.status_code`

This worked in 0.7.6, then 0.8.0 - 0.8.5 there's the `ValueError: invalid literal for int() with base 10: 'user:pass@ip:port'` that contains the proxy details. Then 0.8.6/7 it just takes ages then times out. Here's the stacktrace if I kill it manually

^CTraceback (most recent call last):
File "test.py", line 6, in
resp = requests.get('https://www.google.com/', proxies=proxies)
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/api.py", line 79, in get
return request('get', url, **kwargs)
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/api.py", line 66, in request
prefetch=prefetch
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/sessions.py", line 191, in request
r.send(prefetch=prefetch)
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/models.py", line 462, in send
timeout=self.timeout,
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.py", line 123, in urlopen
return self.proxy_pool.urlopen(method, url, **kw)
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 334, in urlopen
body=body, headers=headers)
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 215, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 941, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 975, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 937, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 797, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 759, in send
self.connect()
File "/Users/peter/.virtualenvs/seo_tools/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 72, in connect
ca_certs=self.ca_certs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 344, in wrap_socket
ciphers=ciphers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 121, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 283, in do_handshake
self._sslobj.do_handshake()
KeyboardInterrupt

Here's where the error happens https://github.com/kennethreitz/requests/blob/develop/requests/models.py#L469 but I'm not sure of the cause. I'm pretty sure this is related to https://github.com/kennethreitz/requests/issues/293.