1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Combine cookies from original request and session file

Close #932
Co-authored-by: kbanc <katherine.bancoft@gmail.com>
Co-authored-by: Gabriel Cruz <gabs.oficial98@gmail.com>
This commit is contained in:
Katherine Bancroft
2020-06-18 17:17:33 -04:00
committed by GitHub
parent 93d07cfe57
commit 9500ce136a
3 changed files with 178 additions and 28 deletions

View File

@@ -4,6 +4,8 @@ Persistent, JSON-serialized sessions.
"""
import os
import re
from http.cookies import SimpleCookie
from pathlib import Path
from typing import Iterable, Optional, Union
from urllib.parse import urlsplit
@@ -76,7 +78,13 @@ class Session(BaseConfigDict):
continue # Ignore explicitly unset headers
value = value.decode('utf8')
if name == 'User-Agent' and value.startswith('HTTPie/'):
if name.lower() == 'user-agent' and value.startswith('HTTPie/'):
continue
if name.lower() == 'cookie':
for cookie_name, morsel in SimpleCookie(value).items():
self['cookies'][cookie_name] = {'value': morsel.value}
del request_headers[name]
continue
for prefix in SESSION_IGNORED_HEADER_PREFIXES: