Skip to content
Myr

cookies.morsel_to_cookie morsel['expires'] can't be strtime, and max-age convert to expires problem repair

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by wasw100 · committed by wasw100 · parent 961790f · Browse files · 1 file+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−1 removed

  • other:+10 added−1 removed

1 file+10 added−1 removed

modified:requests/cookies.py+10 added-1 removed
4 unmodified lines
56requests.utils imports from here, so be careful with imports.7"""89import time10import collections11from .compat import cookielib, urlparse, Morsel1213try:
340 unmodified lines
354355356def morsel_to_cookie(morsel):357 """Convert a Morsel object into a Cookie containing the one k/v pair."""358 expires = None359 if morsel["max-age"]:360 expires = time.time() + morsel["max-age"]361 elif morsel['expires']:362 expires = morsel['expires']363 if type(expires) == type(""):364 time_template = "%a, %d-%b-%Y %H:%M:%S GMT"365 expires = time.mktime(time.strptime(expires, time_template))366 c = create_cookie(367 name=morsel.key,368 value=morsel.value,369 version=morsel['version'] or 0,370 port=None,371 domain=morsel['domain'],372 path=morsel['path'],373 secure=bool(morsel['secure']),365 expires=morsel['max-age'] or morsel['expires'],374 expires=expires,375 discard=False,376 comment=morsel['comment'],377 comment_url=bool(morsel['comment']),378 rest={'HttpOnly': morsel['httponly']},
16 unmodified lines