Skip to content

Commit

Permalink
Fix custom cookies example (#9321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Sep 28, 2024
1 parent 8850a2d commit a4b148e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/client_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------
Expand Down

0 comments on commit a4b148e

Please sign in to comment.