def _new_py_cookie(go_cookie):
'''Convert a Go-style JSON-unmarshaled cookie into a Python cookie'''
expires = None
if go_cookie.get('Expires') is not None:
t = pyrfc3339.parse(go_cookie['Expires'])
expires = t.strftime("%s")
return cookiejar.Cookie(
version=0,
name=go_cookie['Name'],
value=go_cookie['Value'],
port=None,
port_specified=False,
# Unfortunately Python cookies don't record the original
# host that the cookie came from, so we'll just use Domain
# for that purpose, and record that the domain was specified,
# even though it probably was not. This means that
# we won't correctly record the CanonicalHost entry
# when writing the cookie file after reading it.
domain=go_cookie['Domain'],
domain_specified=not go_cookie['HostOnly'],
domain_initial_dot=False,
path=go_cookie['Path'],
path_specified=True,
secure=go_cookie['Secure'],
expires=expires,
discard=False,
comment=None,
comment_url=None,
rest=None,
rfc2109=False,
)
评论列表
文章目录