-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
CookieJar filter_cookies does not preserve expiration date #3951
Comments
|
|
Do you have an idea of how the desired API should look like? |
Below is more or less how I expect def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]':
"""Returns this jar's cookies filtered by their attributes."""
self._do_expiration()
if not isinstance(request_url, URL):
warnings.warn("The method accepts yarl.URL instances only, got {}"
.format(type(request_url)),
DeprecationWarning)
request_url = URL(request_url)
filtered = SimpleCookie()
hostname = request_url.raw_host or ""
is_not_secure = request_url.scheme not in ("https", "wss")
for cookie in self:
name = cookie.key
domain = cookie["domain"]
# Send shared cookies
if not domain:
# Assign original Morsel (or a full copy) to `filtered[name]`.
filtered[name] = cookie
continue
if not self._unsafe and is_ip_address(hostname):
continue
if (domain, name) in self._host_only_cookies:
if domain != hostname:
continue
elif not self._is_domain_match(domain, hostname):
continue
if not self._is_path_match(request_url.path, cookie["path"]):
continue
if is_not_secure and cookie["secure"]:
continue
# Assign original Morsel (or a full copy) to `filtered[name]`.
filtered[name] = cookie
return filtered |
Long story short
Using
CookieJar.filter_cookies()
does not preserve the expiration date of the returned cookies.Expected behaviour
Return the full cookie Morsels that have the
expires
,domain
,path
, etc. fields.Actual behaviour
The
expires
field is not included in the cookie Morsels returned fromCookieJar.filter_cookies()
.Steps to reproduce
Here's a full working example to demonstrate. It's a contrived example, but it gets the point across. Iterating through
cookie_jar
gives me the full Morsel objects with expiration. But iterating throughfiltered_cookies
does not contain the expiration.Your environment
I'm using the latest stable release of aiohttp (3.5.4).
The text was updated successfully, but these errors were encountered: