From 52e0b917ddbba93cececb32587928583d66f5f61 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 28 Sep 2024 02:38:21 +0100 Subject: [PATCH] Fix custom cookies example (#9321) (#9324) (cherry picked from commit a4b148e84dacfaac3b17c6cb5f5ca3025b0e4914) --- 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 26594a21b1c..524b0877450 100644 --- a/docs/client_advanced.rst +++ b/docs/client_advanced.rst @@ -82,14 +82,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( - '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 ----------------------------