Created
February 15, 2022 18:38
-
-
Save lafftar/a1ac3f3e47487bb260dc0e2c130410b9 to your computer and use it in GitHub Desktop.
Removing default headers from aiohttp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aiohttp import ClientSession, ClientRequest | |
class CustomRequestClass(ClientRequest): | |
DEFAULT_HEADERS = {} | |
pass | |
async def main(): | |
async with ClientSession(headers={"User-Agent": 'Dario\'sGodBot', "Host": "httpbin.org"}, | |
request_class=CustomRequestClass) \ | |
as sesh: | |
res = await sesh.request(method='GET', url='http://httpbin.org/get') | |
print(dumps(await res.json(), indent=4)) | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment