Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ Patches and ideas
* `Edward Yang <https://github.com/honorabrutroll>`_
* `Aleksandr Vinokurov <https://github.com/aleksandr-vin>`_
* `Jeff Byrnes <https://github.com/jeffbyrnes>`_
* `Denis Belavin <https://github.com/LuckyDenis>`_


9 changes: 9 additions & 0 deletions httpie/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def is_expired(expires: Optional[float]) -> bool:
for attrs in attr_sets
]

# HACK/FIXME: https://github.com/psf/requests/issues/5743
for cookie in cookies:
if 'expires' in cookie:
continue

max_age = cookie.get('max-age')
if max_age and max_age.isdigit():
cookie['expires'] = now + float(max_age)

Comment thread
jkbrzt marked this conversation as resolved.
return [
{
'name': cookie['name'],
Expand Down
9 changes: 9 additions & 0 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ def test_expired_cookies(self, httpbin):
assert 'cookie1' in updated_session['cookies']
assert 'cookie2' not in updated_session['cookies']

def test_get_expired_cookies_using_max_age(self):
headers = [
('Set-Cookie', 'one=two; Max-Age=0; path=/; domain=.tumblr.com; HttpOnly')
]
expected_expired = [
{'name': 'one', 'path': '/'}
]
assert get_expired_cookies(headers, now=None) == expected_expired

@pytest.mark.parametrize(
argnames=['headers', 'now', 'expected_expired'],
argvalues=[
Expand Down