python 2.7中的HTTP 2请求 [英] HTTP 2 request in python 2.7
问题描述
在python中向HTTP/1和HTTP/2发出请求有什么区别.
Is there any difference in making request to HTTP/1 and HTTP/2 in python.
我可以像在python中那样进行HTTP/1.x调用
I can make HTTP/1.x calls in python like
url = 'http://someURL'
values = {'param1' : 'key',
'param2' : 'key2'}
data = urllib.urlencode(values)
print data
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page
python是否默认支持HTTP/2,还是应该添加其他内容?
Is python supporting making HTTP/2 by default or should I add anything extra.
推荐答案
正如问题注释中提到的其他内容一样,requests
库不支持HTTP/2.
As others mentioned in the comments to the question the requests
library does not support HTTP/2.
从requests
库文档:
Requests(请求)允许您发送基本的,自然的 HTTP/1.1 请求,而无需进行人工操作.
Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor.
到目前为止,我所知道的唯一的Python HTTP/2客户端是 hyper
,其中引用了文档:
As of now the only HTTP/2 client for Python I know of is hyper
, which quoting from the docs:
支持Python 3.4和Python 2.7.9,并且可以说HTTP/2和HTTP/1.1
supports Python 3.4 and Python 2.7.9, and can speak HTTP/2 and HTTP/1.1
这篇关于python 2.7中的HTTP 2请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!