From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- third_party/python/aiohttp/examples/client_auth.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 third_party/python/aiohttp/examples/client_auth.py (limited to 'third_party/python/aiohttp/examples/client_auth.py') diff --git a/third_party/python/aiohttp/examples/client_auth.py b/third_party/python/aiohttp/examples/client_auth.py new file mode 100755 index 0000000000..6513de20e5 --- /dev/null +++ b/third_party/python/aiohttp/examples/client_auth.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import asyncio + +import aiohttp + + +async def fetch(session): + print("Query http://httpbin.org/basic-auth/andrew/password") + async with session.get("http://httpbin.org/basic-auth/andrew/password") as resp: + print(resp.status) + body = await resp.text() + print(body) + + +async def go(loop): + async with aiohttp.ClientSession( + auth=aiohttp.BasicAuth("andrew", "password"), loop=loop + ) as session: + await fetch(session) + + +loop = asyncio.get_event_loop() +loop.run_until_complete(go(loop)) -- cgit v1.2.3