Thomas Young
Thomas Young

Reputation: 316

Does python-requests support HTTP2 and asynchronous calls?

I would like to use python-requests in my server to send PUSH notification to Apple push server, my questions:

  1. Does python-requests support asynchronous calls?
  2. Does python-request support HTTP2?

Upvotes: 14

Views: 38625

Answers (2)

Greg Dubicki
Greg Dubicki

Reputation: 6950

As recommended by @qris in this comment, you should consider using HTTPX (https://github.com/encode/httpx/) .

It's in beta, but a 1.0 release is planned.

It supports both async as well as HTTP/2 and provides a requests-compatible API.

Upvotes: 11

Huang
Huang

Reputation: 609

It doesn't support HTTP/2 now (Release v2.18.1). As in the doc (http://docs.python-requests.org/en/master/):

Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor.

But you can try Hyper if you need to send HTTP/2 requests: https://hyper.readthedocs.io/en/latest/.

hyper supports Python 3.4 and Python 2.7.9, and can speak HTTP/2 and HTTP/1.1.

Upvotes: 2

Related Questions