def format_cookies(cookie_list): rv = [] for name, value, attrs in cookie_list: cookie_har = { "name": name, "value": value, } # HAR only needs some attributes for key in ["path", "domain", "comment"]: if key in attrs: cookie_har[key] = attrs[key] # These keys need to be boolean! for key in ["httpOnly", "secure"]: cookie_har[key] = bool(key in attrs) # Expiration time needs to be formatted expire_ts = cookies.get_expiration_ts(attrs) if expire_ts is not None: cookie_har["expires"] = format_datetime(datetime.fromtimestamp(expire_ts)) rv.append(cookie_har) return rv
def format_cookies(cookie_list): rv = [] for name, value, attrs in cookie_list: cookie_har = { "name": name, "value": value, } # HAR only needs some attributes for key in ["path", "domain", "comment"]: if key in attrs: cookie_har[key] = attrs[key] # These keys need to be boolean! for key in ["httpOnly", "secure"]: cookie_har[key] = bool(key in attrs) # Expiration time needs to be formatted expire_ts = cookies.get_expiration_ts(attrs) if expire_ts is not None: cookie_har["expires"] = datetime.fromtimestamp(expire_ts, timezone.utc).isoformat() rv.append(cookie_har) return rv
def format_cookies(cookie_list): rv = [] for name, value, attrs in cookie_list: cookie_har = { 'name': name, 'value': value, } for key in ['path', 'domain', 'comment']: if key in attrs: cookie_har[key] = attrs[key] for key in ['httpOnly', 'secure']: cookie_har[key] = bool(key in attrs) expire_ts = cookies.get_expiration_ts(attrs) if expire_ts is not None: cookie_har['expires'] = datetime.fromtimestamp( expire_ts, timezone.utc).isoformat() rv.append(cookie_har) return rv