From a4b148e84dacfaac3b17c6cb5f5ca3025b0e4914 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 28 Sep 2024 01:58:47 +0100 Subject: [PATCH] Fix custom cookies example (#9321) --- docs/client_advanced.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/client_advanced.rst b/docs/client_advanced.rst index 19a4c196c33..754f030d237 100644 --- a/docs/client_advanced.rst +++ b/docs/client_advanced.rst @@ -120,14 +120,14 @@ parameter of :class:`ClientSession` constructor:: between multiple requests:: async with aiohttp.ClientSession() as session: - await session.get( - 'http://httpbin.org/cookies/set?my_cookie=my_value') - filtered = session.cookie_jar.filter_cookies( - URL('http://httpbin.org')) - assert filtered['my_cookie'].value == 'my_value' - async with session.get('http://httpbin.org/cookies') as r: + async with session.get( + "http://httpbin.org/cookies/set?my_cookie=my_value", + allow_redirects=False + ) as resp: + assert resp.cookies["my_cookie"].value == "my_value" + async with session.get("http://httpbin.org/cookies") as r: json_body = await r.json() - assert json_body['cookies']['my_cookie'] == 'my_value' + assert json_body["cookies"]["my_cookie"] == "my_value" Response Headers and Cookies ----------------------------