mirror of
https://github.com/httpie/cli.git
synced 2024-11-25 01:03:27 +01:00
Cleanup
This commit is contained in:
parent
f1ab816ecd
commit
490eeaa650
@ -6,7 +6,7 @@ import ssl
|
||||
|
||||
|
||||
# TODO: Use MultiDict for headers once added to `requests`.
|
||||
# https://github.com/jakubroztocil/httpie/issues/130
|
||||
# <https://github.com/jakubroztocil/httpie/issues/130>
|
||||
|
||||
|
||||
# ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
||||
|
@ -183,13 +183,13 @@ def finalize_headers(headers: RequestHeadersDict) -> RequestHeadersDict:
|
||||
final_headers = RequestHeadersDict()
|
||||
for name, value in headers.items():
|
||||
if value is not None:
|
||||
# >leading or trailing LWS MAY be removed without
|
||||
# >changing the semantics of the field value"
|
||||
# -https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
|
||||
# “leading or trailing LWS MAY be removed without
|
||||
# changing the semantics of the field value”
|
||||
# <https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html>
|
||||
# Also, requests raises `InvalidHeader` for leading spaces.
|
||||
value = value.strip()
|
||||
if isinstance(value, str):
|
||||
# See: https://github.com/jakubroztocil/httpie/issues/212
|
||||
# See <https://github.com/jakubroztocil/httpie/issues/212>
|
||||
value = value.encode('utf8')
|
||||
final_headers[name] = value
|
||||
return final_headers
|
||||
|
@ -21,7 +21,7 @@ DEFAULT_SESSIONS_DIR = DEFAULT_CONFIG_DIR / SESSIONS_DIR_NAME
|
||||
VALID_SESSION_NAME_PATTERN = re.compile('^[a-zA-Z0-9_.-]+$')
|
||||
# Request headers starting with these prefixes won't be stored in sessions.
|
||||
# They are specific to each request.
|
||||
# https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Requests
|
||||
# <https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Requests>
|
||||
SESSION_IGNORED_HEADER_PREFIXES = ['Content-', 'If-']
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ class Session(BaseConfigDict):
|
||||
|
||||
@cookies.setter
|
||||
def cookies(self, jar: RequestsCookieJar):
|
||||
# https://docs.python.org/2/library/cookielib.html#cookie-objects
|
||||
# <https://docs.python.org/2/library/cookielib.html#cookie-objects>
|
||||
stored_attrs = ['value', 'path', 'secure', 'expires']
|
||||
self['cookies'] = {}
|
||||
for cookie in jar:
|
||||
|
Loading…
Reference in New Issue
Block a user