summaryrefslogtreecommitdiffstats
path: root/yt_dlp/networking/_requests.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/networking/_requests.py')
-rw-r--r--yt_dlp/networking/_requests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/yt_dlp/networking/_requests.py b/yt_dlp/networking/_requests.py
index e3edc77..6397a2c 100644
--- a/yt_dlp/networking/_requests.py
+++ b/yt_dlp/networking/_requests.py
@@ -28,6 +28,7 @@ import requests.adapters
import requests.utils
import urllib3.connection
import urllib3.exceptions
+import urllib3.util
from ._helper import (
InstanceStoreMixin,
@@ -180,10 +181,25 @@ class RequestsHTTPAdapter(requests.adapters.HTTPAdapter):
extra_kwargs['proxy_ssl_context'] = self._proxy_ssl_context
return super().proxy_manager_for(proxy, **proxy_kwargs, **self._pm_args, **extra_kwargs)
+ # Skip `requests` internal verification; we use our own SSLContext
+ # requests 2.31.0+
def cert_verify(*args, **kwargs):
- # lean on SSLContext for cert verification
pass
+ # requests 2.31.0-2.32.1
+ def _get_connection(self, request, *_, proxies=None, **__):
+ return self.get_connection(request.url, proxies)
+
+ # requests 2.32.2+: Reimplementation without `_urllib3_request_context`
+ def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
+ url = urllib3.util.parse_url(request.url).url
+
+ manager = self.poolmanager
+ if proxy := select_proxy(url, proxies):
+ manager = self.proxy_manager_for(proxy)
+
+ return manager.connection_from_url(url)
+
class RequestsSession(requests.sessions.Session):
"""