mirror of
https://github.com/httpie/cli.git
synced 2024-11-22 15:53:13 +01:00
Cleanup
This commit is contained in:
parent
4c4efff56a
commit
27d57ce773
@ -9,6 +9,8 @@ from typing import Iterable, Union
|
|||||||
from urllib.parse import urlparse, urlunparse
|
from urllib.parse import urlparse, urlunparse
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
# noinspection PyPackageRequirements
|
||||||
|
import urllib3
|
||||||
|
|
||||||
from httpie import __version__
|
from httpie import __version__
|
||||||
from httpie.cli.dicts import RequestHeadersDict
|
from httpie.cli.dicts import RequestHeadersDict
|
||||||
@ -18,15 +20,7 @@ from httpie.ssl import AVAILABLE_SSL_VERSION_ARG_MAPPING, HTTPieHTTPSAdapter
|
|||||||
from httpie.utils import repr_dict
|
from httpie.utils import repr_dict
|
||||||
|
|
||||||
|
|
||||||
try:
|
urllib3.disable_warnings()
|
||||||
# noinspection PyPackageRequirements
|
|
||||||
import urllib3
|
|
||||||
|
|
||||||
|
|
||||||
# <https://urllib3.readthedocs.io/en/latest/security.html>
|
|
||||||
urllib3.disable_warnings()
|
|
||||||
except (ImportError, AttributeError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=utf-8'
|
FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=utf-8'
|
||||||
JSON_CONTENT_TYPE = 'application/json'
|
JSON_CONTENT_TYPE = 'application/json'
|
||||||
|
@ -32,12 +32,11 @@ class HTTPieHTTPSAdapter(HTTPAdapter):
|
|||||||
ciphers: str = None,
|
ciphers: str = None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
self._ssl_context = create_urllib3_context(
|
self._ssl_context = self._create_ssl_context(
|
||||||
|
verify=verify,
|
||||||
|
ssl_version=ssl_version,
|
||||||
ciphers=ciphers,
|
ciphers=ciphers,
|
||||||
ssl_version=resolve_ssl_version(ssl_version),
|
|
||||||
cert_reqs=ssl.CERT_REQUIRED if verify else ssl.CERT_NONE
|
|
||||||
)
|
)
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def init_poolmanager(self, *args, **kwargs):
|
def init_poolmanager(self, *args, **kwargs):
|
||||||
@ -47,3 +46,18 @@ class HTTPieHTTPSAdapter(HTTPAdapter):
|
|||||||
def proxy_manager_for(self, *args, **kwargs):
|
def proxy_manager_for(self, *args, **kwargs):
|
||||||
kwargs['ssl_context'] = self._ssl_context
|
kwargs['ssl_context'] = self._ssl_context
|
||||||
return super().proxy_manager_for(*args, **kwargs)
|
return super().proxy_manager_for(*args, **kwargs)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _create_ssl_context(
|
||||||
|
verify: bool,
|
||||||
|
ssl_version: str = None,
|
||||||
|
ciphers: str = None,
|
||||||
|
) -> ssl.SSLContext:
|
||||||
|
return create_urllib3_context(
|
||||||
|
ciphers=ciphers,
|
||||||
|
ssl_version=resolve_ssl_version(ssl_version),
|
||||||
|
# Since we are using a custom SSL context, we need to pass this
|
||||||
|
# here manually, even though it’s also passed to the connection
|
||||||
|
# in `super().cert_verify()`.
|
||||||
|
cert_reqs=ssl.CERT_REQUIRED if verify else ssl.CERT_NONE
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user