Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does urllib3 support HTTP/2 Requests? Will it?

I know the following about various python HTTP libraries:

  • Requests does not support HTTP/2 requests.
  • Hyper does support HTTP/2 requests, but is archived as of early 2021 and wouldn't be a good choice for new projects.
  • HTTPX does support HTTP/2, but this support is optional, requires installing extra dependencies, and comes with some caveats about rough edges.
  • AIOHTTP does not support HTTP2 yet (as of mid April 2022).
    • The focus of this project is also not solely on being a client -- this package also includes a server.

The other major HTTP request library I'm aware of is urllib3. This is what OpenAPI Generator uses by default when generating python client libraries.

My Questions are:

Can urrlib3 be configured to make HTTP/2 requests?

I cannot find any information on http2 support in the documentation, and through my testing of a generated OpenAPI client, all requests are HTTP/1.1. If the answer is no currently, are the maintainers planning HTTP/2 support? I cannot find any evidence of this in the project's open issues.

like image 383
kashev Avatar asked Mar 13 '26 20:03

kashev


1 Answers

Edit 2025/06/04: About a year after I asked about this, the urllib3 team does appear to have started working on HTTP/2 support, incrementally. Reference this github issue. The support doesn't appear to be complete as of this writing, but the correct answer used to be "urllib3 does not support HTTP/2 and will not" and now the correct answer is "urllib3 does not yet fully support HTTP/2, but that support is in work".

---

I asked about this in the urllib3 discord, and got an answer from one of the maintainers that corroborates what Tim Roberts commented;

  • Proper HTTP/2 implementations require async/await to take advantage of the main different feature in HTTP/2, which is making requests in parallel.
  • urllib3 in particular is not planning to support this because it'll in general require a rewrite.
like image 100
kashev Avatar answered Mar 15 '26 10:03

kashev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!