Change venv
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import absolute_import
|
||||
|
||||
import errno
|
||||
import logging
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import warnings
|
||||
@@ -35,7 +36,6 @@ from .exceptions import (
|
||||
)
|
||||
from .packages import six
|
||||
from .packages.six.moves import queue
|
||||
from .packages.ssl_match_hostname import CertificateError
|
||||
from .request import RequestMethods
|
||||
from .response import HTTPResponse
|
||||
from .util.connection import is_connection_dropped
|
||||
@@ -44,6 +44,7 @@ from .util.queue import LifoQueue
|
||||
from .util.request import set_file_position
|
||||
from .util.response import assert_header_parsing
|
||||
from .util.retry import Retry
|
||||
from .util.ssl_match_hostname import CertificateError
|
||||
from .util.timeout import Timeout
|
||||
from .util.url import Url, _encode_target
|
||||
from .util.url import _normalize_host as normalize_host
|
||||
@@ -301,8 +302,11 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
||||
pass
|
||||
except queue.Full:
|
||||
# This should never happen if self.block == True
|
||||
log.warning("Connection pool is full, discarding connection: %s", self.host)
|
||||
|
||||
log.warning(
|
||||
"Connection pool is full, discarding connection: %s. Connection pool size: %s",
|
||||
self.host,
|
||||
self.pool.qsize(),
|
||||
)
|
||||
# Connection never got put back into the pool, close it.
|
||||
if conn:
|
||||
conn.close()
|
||||
@@ -375,7 +379,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
||||
|
||||
timeout_obj = self._get_timeout(timeout)
|
||||
timeout_obj.start_connect()
|
||||
conn.timeout = timeout_obj.connect_timeout
|
||||
conn.timeout = Timeout.resolve_default_timeout(timeout_obj.connect_timeout)
|
||||
|
||||
# Trigger any extra validation we need to do.
|
||||
try:
|
||||
@@ -745,7 +749,35 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
||||
# Discard the connection for these exceptions. It will be
|
||||
# replaced during the next _get_conn() call.
|
||||
clean_exit = False
|
||||
if isinstance(e, (BaseSSLError, CertificateError)):
|
||||
|
||||
def _is_ssl_error_message_from_http_proxy(ssl_error):
|
||||
# We're trying to detect the message 'WRONG_VERSION_NUMBER' but
|
||||
# SSLErrors are kinda all over the place when it comes to the message,
|
||||
# so we try to cover our bases here!
|
||||
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
|
||||
return (
|
||||
"wrong version number" in message or "unknown protocol" in message
|
||||
)
|
||||
|
||||
# Try to detect a common user error with proxies which is to
|
||||
# set an HTTP proxy to be HTTPS when it should be 'http://'
|
||||
# (ie {'http': 'http://proxy', 'https': 'https://proxy'})
|
||||
# Instead we add a nice error message and point to a URL.
|
||||
if (
|
||||
isinstance(e, BaseSSLError)
|
||||
and self.proxy
|
||||
and _is_ssl_error_message_from_http_proxy(e)
|
||||
and conn.proxy
|
||||
and conn.proxy.scheme == "https"
|
||||
):
|
||||
e = ProxyError(
|
||||
"Your proxy appears to only use HTTP and not HTTPS, "
|
||||
"try changing your proxy URL to be HTTP. See: "
|
||||
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
||||
"#https-proxy-error-http-proxy",
|
||||
SSLError(e),
|
||||
)
|
||||
elif isinstance(e, (BaseSSLError, CertificateError)):
|
||||
e = SSLError(e)
|
||||
elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
|
||||
e = ProxyError("Cannot connect to proxy.", e)
|
||||
@@ -830,7 +862,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
||||
)
|
||||
|
||||
# Check if we should retry the HTTP response.
|
||||
has_retry_after = bool(response.getheader("Retry-After"))
|
||||
has_retry_after = bool(response.headers.get("Retry-After"))
|
||||
if retries.is_retry(method, response.status, has_retry_after):
|
||||
try:
|
||||
retries = retries.increment(method, url, response=response, _pool=self)
|
||||
@@ -1020,6 +1052,17 @@ class HTTPSConnectionPool(HTTPConnectionPool):
|
||||
InsecureRequestWarning,
|
||||
)
|
||||
|
||||
if getattr(conn, "proxy_is_verified", None) is False:
|
||||
warnings.warn(
|
||||
(
|
||||
"Unverified HTTPS connection done to an HTTPS proxy. "
|
||||
"Adding certificate verification is strongly advised. See: "
|
||||
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
||||
"#ssl-warnings"
|
||||
),
|
||||
InsecureRequestWarning,
|
||||
)
|
||||
|
||||
|
||||
def connection_from_url(url, **kw):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user