Add basic HTTP/2 example

This commit is contained in:
agatha 2023-10-11 17:35:54 -04:00
parent c6ac417946
commit 0c7119dbeb
3 changed files with 30 additions and 2 deletions

View File

@ -0,0 +1,26 @@
import asyncio
import httpx
async def make_http2_request(url):
try:
async with httpx.AsyncClient(http2=True, verify=False) as client:
response = await client.get(url)
return response
except httpx.RequestError as e:
print(f'[!] error occurred while making the request: {e}')
return None
def main():
url = 'https://localhost/'
response = asyncio.run(make_http2_request(url))
print('Response object type:', type(response))
print('Response HTTP version:', response.http_version)
print('Response headers:', response.headers)
if __name__ == '__main__':
main()

View File

@ -1,2 +1,3 @@
httpx asyncio
h2 h2
httpx[http2]

1
src/rr.py Normal file
View File

@ -0,0 +1 @@
"""rrpoc"""