0

I cant seem to find a way to send http connect 1.1 using python requests with proxy. it sends 1.0 and I dont want my infra to be able to accept http 1.0 connections.

proxy = { 'https': f'http://{xyz}:10000' }
requests.get(
    f'https://{url}/health',
    timeout = 10,
    proxies = proxy
)

this results in something like: HTTP/1.1 426 Upgrade Required

using curl as a workaround for now

edit: python 3.10.9, requests==2.26.0
edit: found this line: https://github.com/python/cpython/blob/940763140f7519a125229782ca7a095af01edda4/Lib/http/client.py#L907

so its literally hardcoded to 1.0 for tunneling scenarios?

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • note the schema in the value - it's `http://`, not `https://` – buran Jan 17 '23 at 15:24
  • thats correct, i'm sending a request to an https endpoint, but the proxy is http (that is expected as well) – 4c74356b41 Jan 17 '23 at 15:26
  • Does this answer your question? [Writing a GET request to return HTTP 1.1 instead of 1.0](https://stackoverflow.com/questions/69747484/writing-a-get-request-to-return-http-1-1-instead-of-1-0) – Amin S Jan 17 '23 at 15:41
  • no, it looks like this code is for http server, whereas I need to send a request, not respond to a request – 4c74356b41 Jan 17 '23 at 15:45
  • Does this answer your question? [Requests Library Force Use of HTTP/1.1 On HTTPS Proxy CONNECT](https://stackoverflow.com/questions/43380862/requests-library-force-use-of-http-1-1-on-https-proxy-connect) – felipe Jan 18 '23 at 04:36
  • nope, still getting `'Tunnel connection failed: 426 Upgrade Required'` – 4c74356b41 Jan 18 '23 at 04:44

0 Answers0