简体   繁体   English

urllib3 是否支持 HTTP/2 请求? 会吗?

[英]Does urllib3 support HTTP/2 Requests? Will it?

I know the following about various python HTTP libraries:我知道以下关于各种 python HTTP 库的信息:

The other major HTTP request library I'm aware of is urllib3 .我知道的另一个主要的 HTTP 请求库是urllib3 This is what OpenAPI Generator uses by default when generating python client libraries.这是OpenAPI Generator在生成 python 客户端库时默认使用的内容。

My Questions are:我的问题是:

Can urrlib3 be configured to make HTTP/2 requests?可以将 urrlib3 配置为发出 HTTP/2 请求吗?

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.我在 文档中找不到任何关于 http2 支持的信息,并且通过我对生成的 OpenAPI 客户端的测试,所有请求都是 HTTP/1.1。 If the answer is no currently, are the maintainers planning HTTP/2 support ?如果目前答案是否定的,维护者是否计划支持 HTTP/2 I cannot find any evidence of this in the project's open issues .我在项目的未解决问题中找不到任何证据。

I asked about this in the urllib3 discord, and got an answer from one of the maintainers that corroborates what Tim Roberts commented;我在 urllib3 discord 中询问了这个问题,并从一位维护者那里得到了证实Tim Roberts评论的答案;

  • Proper HTTP/2 implementations require async/await to take advantage of the main different feature in HTTP/2, which is making requests in parallel .正确的 HTTP/2 实现需要 async/await 来利用 HTTP/2 中的主要不同特性,即并行发出请求
  • urllib3 in particular is not planning to support this because it'll in general require a rewrite.特别是 urllib3 不打算支持它,因为它通常需要重写。

There is an alternative to the listed HTTP/2 clients: pycurl can perform HTTP/2 requests very efficiently if libcurl is compiled with HTTP/2 support (same apply to HTTP/3).列出的 HTTP/2 客户端有一个替代方案:如果libcurl编译时支持 HTTP/2(同样适用于 HTTP/3), pycurl可以非常有效地执行 HTTP/2 请求。 The drawback is it's more complex to install.缺点是安装比较复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM