I have a url that only responds to http2 requests.
When I want send http/2 request with python to the URL, I get bellow ERROR
:
h2.exceptions.ProtocolError: Received duplicate pseudo-header field b':path'
My Code
:
from hyper.contrib import HTTP20Adapter
import requests
MyHeader={
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}
adapter = HTTP20Adapter(headers=MyHeader)
sessions=requests.session()
sessions.mount(prefix='https://myurl.com', adapter=adapter)
r=sessions.get('Continue_My_Url_response')
print(r)
I use too many requests
library for HTTP/1
and this is first time I want work with HTTP/2
.
Any body have idea and example for send this request over HTTP/2
?
Use httpx with http/2 support enabled: httpx.Client(http2=True)
.