-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aiohttp ignoring cookie_jar quote_cookie parameter #9336
Comments
Please create a complete reproducer (or better, a failing test in a PR). |
i updated the reproduce section to contain a full example |
Lines 576 to 583 in 24b0e6f
If cookies are directly passed to the manually created import aiohttp
import asyncio
async def req():
tcp_conn = aiohttp.TCPConnector(limit=10, force_close=True)
c_jar = aiohttp.CookieJar(quote_cookie=False)
sess = aiohttp.ClientSession(connector=tcp_conn, cookie_jar=c_jar)
cookies = {"name": "val="}
c_jar.update_cookies(cookies)
resp = await sess.request(url="http://localhost:8000/", method="GET")
print(resp.request_info.headers.get("Cookie")) # name=val=
await sess.close()
asyncio.run(req()) |
So, perhaps we should be reusing the settings from the global CookieJar. Think you could turn that into a full test? |
Describe the bug
When using an client session object with a cookie jar with the cookie quoting routine disabled the requests sent still uses quoting routine when invoking the request:
[client_reqrep.py:468] ClientRequest().update_cookies():
The variable
c
used to output the cookie is a SimpleCookie object which defaults to using the quoting routine.therefor when for example received a cookie with value such as
id=!IagQHEStKHLB3DFBAufSQIeK+Olw=
the header will output asCookie: id="!IagQHEStKHLB3DFBAufSQIeK+Olw="
.A possible fix is to add a method to the CookieJar object like
is_quote_disabled()
and then in the update cookies use theself.session.is_quoting_disabled()
to specifically handle the cookie in such case. i used:To Reproduce
use the following script to reproduce:
Expected behavior
When specifying quote_cookie to False, cookie which by specifications are supposed to be quoted shouldn't be quoted because of the implicit flag.
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Mac OS
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: