Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue of sending a HTTPS request use http proxy #1318

Closed
howie1013 opened this issue Apr 22, 2013 · 1 comment
Closed

Issue of sending a HTTPS request use http proxy #1318

howie1013 opened this issue Apr 22, 2013 · 1 comment

Comments

@howie1013
Copy link

I try to sending a HTTPS requests by http proxy.

the code is like

proxy = 'host:port'
proxies = {'https' : proxy}
r = requests.post('https://url', proxies=proxies, timeout=10)

But it just raises the error below, while I tested it OK when using pycurl.

Traceback (most recent call last):
  File "c:\python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\packages\urllib3\connectionpool.py", line 421, in urlopen
    body=body, headers=headers)
  File "c:\python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\packages\urllib3\connectionpool.py", line 273, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "c:\python32\lib\http\client.py", line 964, in request
    self._send_request(method, url, body, headers)
  File "c:\python32\lib\http\client.py", line 1002, in _send_request
    self.endheaders(body)
  File "c:\python32\lib\http\client.py", line 960, in endheaders
    self._send_output(message_body)
  File "c:\python32\lib\http\client.py", line 805, in _send_output
    self.send(msg)
  File "c:\python32\lib\http\client.py", line 743, in send
    self.connect()
  File "c:\python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\packages\urllib3\connectionpool.py", line 104, in connect
    ssl_version=resolved_ssl_version)
  File "c:\python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\packages\urllib3\util.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "c:\python32\lib\ssl.py", line 181, in wrap_socket
    _context=self)
  File "c:\python32\lib\ssl.py", line 268, in __init__
    raise x
  File "c:\python32\lib\ssl.py", line 264, in __init__
    self.do_handshake()
  File "c:\python32\lib\ssl.py", line 443, in do_handshake
    self._sslobj.do_handshake()
socket.timeout: _ssl.c:376: The handshake operation timed out
@Lukasa
Copy link
Member

Lukasa commented Apr 23, 2013

Unfortunately, Requests is in an awkward place with proxies and HTTPS at the moment. You cannot use the HTTP CONNECT verb, which means the only kind of proxy you can use with HTTPS traffic is an SSL-terminating proxy like mitmproxy.

The specific bug here is that we're attempting to connect to your proxy and perform the SSL handshake, but the proxy is either not responding or taking too long to respond.

Until the CONNECT verb is implemented in urllib3 (see urllib3/urllib3#170), you will not be able to do what you're attempting to do using Requests.

Sorry we can't do more to help you, and thanks for reporting the bug!

@Lukasa Lukasa closed this as completed Apr 23, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants