This commit is contained in:
Jakub Roztocil 2019-09-01 21:15:39 +02:00
parent bd3208cf24
commit 45e8e4e4ea
2 changed files with 14 additions and 7 deletions

View File

@ -19,6 +19,8 @@ from httpie.utils import repr_dict
try: try:
# noinspection PyPackageRequirements # noinspection PyPackageRequirements
import urllib3 import urllib3
# <https://urllib3.readthedocs.io/en/latest/security.html> # <https://urllib3.readthedocs.io/en/latest/security.html>
urllib3.disable_warnings() urllib3.disable_warnings()
except (ImportError, AttributeError): except (ImportError, AttributeError):
@ -181,7 +183,10 @@ def make_default_headers(args: argparse.Namespace) -> RequestHeadersDict:
return default_headers return default_headers
def make_requests_kwargs(args: argparse.Namespace, base_headers=None) -> dict: def make_requests_kwargs(
args: argparse.Namespace,
base_headers: RequestHeadersDict = None
) -> dict:
""" """
Translate our `args` into `requests.request` keyword arguments. Translate our `args` into `requests.request` keyword arguments.

View File

@ -12,6 +12,7 @@ from requests.auth import AuthBase
from requests.cookies import RequestsCookieJar, create_cookie from requests.cookies import RequestsCookieJar, create_cookie
import requests import requests
from httpie.cli.dicts import RequestHeadersDict
from httpie.config import BaseConfigDict, DEFAULT_CONFIG_DIR from httpie.config import BaseConfigDict, DEFAULT_CONFIG_DIR
from httpie.plugins import plugin_manager from httpie.plugins import plugin_manager
@ -101,14 +102,13 @@ class Session(BaseConfigDict):
def _get_path(self) -> Path: def _get_path(self) -> Path:
return self._path return self._path
def update_headers(self, request_headers: dict): def update_headers(self, request_headers: RequestHeadersDict):
""" """
Update the session headers with the request ones while ignoring Update the session headers with the request ones while ignoring
certain name prefixes. certain name prefixes.
:type request_headers: dict
""" """
headers = self.headers
for name, value in request_headers.items(): for name, value in request_headers.items():
if value is None: if value is None:
@ -122,11 +122,13 @@ class Session(BaseConfigDict):
if name.lower().startswith(prefix.lower()): if name.lower().startswith(prefix.lower()):
break break
else: else:
self['headers'][name] = value headers[name] = value
self['headers'] = dict(headers)
@property @property
def headers(self) -> dict: def headers(self) -> RequestHeadersDict:
return self['headers'] return RequestHeadersDict(self['headers'])
@property @property
def cookies(self) -> RequestsCookieJar: def cookies(self) -> RequestsCookieJar: