mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
bpo-12144: Handle cookies with expires attribute in CookieJar.make_cookies (GH-13921)
Handle time comparison for cookies with `expires` attribute when `CookieJar.make_cookies` is called. Co-authored-by: Demian Brecht <demianbrecht@gmail.com> https://bugs.python.org/issue12144 Automerge-Triggered-By: @asvetlov
This commit is contained in:
parent
d31b31516c
commit
bb41147eab
3 changed files with 12 additions and 2 deletions
|
|
@ -585,6 +585,15 @@ class CookieTests(unittest.TestCase):
|
|||
# if expires is in future, keep cookie...
|
||||
c = CookieJar()
|
||||
future = time2netscape(time.time()+3600)
|
||||
|
||||
with test.support.check_no_warnings(self):
|
||||
headers = [f"Set-Cookie: FOO=BAR; path=/; expires={future}"]
|
||||
req = urllib.request.Request("http://www.coyote.com/")
|
||||
res = FakeResponse(headers, "http://www.coyote.com/")
|
||||
cookies = c.make_cookies(res, req)
|
||||
self.assertEqual(len(cookies), 1)
|
||||
self.assertEqual(time2netscape(cookies[0].expires), future)
|
||||
|
||||
interact_netscape(c, "http://www.acme.com/", 'spam="bar"; expires=%s' %
|
||||
future)
|
||||
self.assertEqual(len(c), 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue