mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 02:10:59 +00:00
Refactor format_cookies
This commit is contained in:
parent
988174246b
commit
15c488225f
@ -172,10 +172,10 @@ def format_datetime(dt):
|
|||||||
return dt.replace(tzinfo=pytz.timezone("UTC")).isoformat()
|
return dt.replace(tzinfo=pytz.timezone("UTC")).isoformat()
|
||||||
|
|
||||||
|
|
||||||
def format_cookies(cookies):
|
def format_cookies(cookie_list):
|
||||||
cookie_list = []
|
rv = []
|
||||||
|
|
||||||
for name, value, attrs in cookies:
|
for name, value, attrs in cookie_list:
|
||||||
cookie_har = {
|
cookie_har = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"value": value,
|
"value": value,
|
||||||
@ -192,12 +192,12 @@ def format_cookies(cookies):
|
|||||||
|
|
||||||
# Expiration time needs to be formatted
|
# Expiration time needs to be formatted
|
||||||
expire_ts = cookies.get_expiration_ts(attrs)
|
expire_ts = cookies.get_expiration_ts(attrs)
|
||||||
if expire_ts:
|
if expire_ts is not None:
|
||||||
cookie_har["expires"] = format_datetime(datetime.fromtimestamp(expire_ts))
|
cookie_har["expires"] = format_datetime(datetime.fromtimestamp(expire_ts))
|
||||||
|
|
||||||
cookie_list.append(cookie_har)
|
rv.append(cookie_har)
|
||||||
|
|
||||||
return cookie_list
|
return rv
|
||||||
|
|
||||||
|
|
||||||
def format_request_cookies(fields):
|
def format_request_cookies(fields):
|
||||||
|
Loading…
Reference in New Issue
Block a user