Skip to content
Myr

Merge pull request #1408 from wasw100/master

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

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents f74d5e9, 767f758 · Browse files · 1 file+10 added−5 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−5 removed

  • other:+10 added−5 removed

1 file+10 added−5 removed

modified:requests/cookies.py+10 added-5 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,362 port_specified=False,371 domain=morsel['domain'],364 domain_specified=bool(morsel['domain']),365 domain_initial_dot=morsel['domain'].startswith('.'),372 path=morsel['path'],367 path_specified=bool(morsel['path']),373 secure=bool(morsel['secure']),369 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