mirror of
https://github.com/httpie/cli.git
synced 2025-02-18 02:20:51 +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`.
|
# 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 / "+" / "-" / "." )
|
# ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
||||||
|
@ -183,13 +183,13 @@ def finalize_headers(headers: RequestHeadersDict) -> RequestHeadersDict:
|
|||||||
final_headers = RequestHeadersDict()
|
final_headers = RequestHeadersDict()
|
||||||
for name, value in headers.items():
|
for name, value in headers.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
# >leading or trailing LWS MAY be removed without
|
# “leading or trailing LWS MAY be removed without
|
||||||
# >changing the semantics of the field value"
|
# changing the semantics of the field value”
|
||||||
# -https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
|
# <https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html>
|
||||||
# Also, requests raises `InvalidHeader` for leading spaces.
|
# Also, requests raises `InvalidHeader` for leading spaces.
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
# See: https://github.com/jakubroztocil/httpie/issues/212
|
# See <https://github.com/jakubroztocil/httpie/issues/212>
|
||||||
value = value.encode('utf8')
|
value = value.encode('utf8')
|
||||||
final_headers[name] = value
|
final_headers[name] = value
|
||||||
return final_headers
|
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_.-]+$')
|
VALID_SESSION_NAME_PATTERN = re.compile('^[a-zA-Z0-9_.-]+$')
|
||||||
# Request headers starting with these prefixes won't be stored in sessions.
|
# Request headers starting with these prefixes won't be stored in sessions.
|
||||||
# They are specific to each request.
|
# 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-']
|
SESSION_IGNORED_HEADER_PREFIXES = ['Content-', 'If-']
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class Session(BaseConfigDict):
|
|||||||
|
|
||||||
@cookies.setter
|
@cookies.setter
|
||||||
def cookies(self, jar: RequestsCookieJar):
|
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']
|
stored_attrs = ['value', 'path', 'secure', 'expires']
|
||||||
self['cookies'] = {}
|
self['cookies'] = {}
|
||||||
for cookie in jar:
|
for cookie in jar:
|
||||||
|
Loading…
Reference in New Issue
Block a user