Repository navigation
ill-formed Set-Cookie header cause KeyError #3526
Replies: 1 comment
|
I can reproduce this without httpbin or network access on HTTPX 0.28.1: import httpx
response = httpx.Response(
200,
headers={"set-cookie": "foo"},
request=httpx.Request("GET", "http://example.test/"),
)
print([(c.name, c.value) for c in response.cookies.jar])
# [('foo', None)]
list(response.cookies.items()) # KeyError: 'foo'The underlying cookie jar retains a valueless cookie as That demonstrates an inconsistency between the accepted jar entry and the mapping interface; it does not establish which malformed-header policy maintainers want. For inspection, iterate This reproduction and the empty-value control were tested on Python 3.11 / HTTPX 0.28.1. |
Uh oh!
There was an error while loading. Please reload this page.
when 'Set-Cookie' header is ill-formed, got
KeyErroron iterating cookies.is this intended behavior or an httpx bug?
versions: (httpx was installed by
pip install httpx)step to reproduce:
All reactions