diff --git a/yt_dlp/networking/_requests.py b/yt_dlp/networking/_requests.py index 77113bd72..51cff80fd 100644 --- a/yt_dlp/networking/_requests.py +++ b/yt_dlp/networking/_requests.py @@ -1,6 +1,5 @@ from __future__ import annotations -import contextlib import functools import http.client import logging @@ -101,28 +100,11 @@ def subn(self, repl, string, *args, **kwargs): # https://github.com/urllib3/urllib3/commit/a2697e7c6b275f05879b60f593c5854a816489f0 import urllib3.util.url -if hasattr(urllib3.util.url, 'PERCENT_RE'): - urllib3.util.url.PERCENT_RE = Urllib3PercentREOverride(urllib3.util.url.PERCENT_RE) -elif hasattr(urllib3.util.url, '_PERCENT_RE'): # urllib3 >= 2.0.0 +if hasattr(urllib3.util.url, '_PERCENT_RE'): # was 'PERCENT_RE' in urllib3 < 2.0.0 urllib3.util.url._PERCENT_RE = Urllib3PercentREOverride(urllib3.util.url._PERCENT_RE) else: warnings.warn('Failed to patch PERCENT_RE in urllib3 (does the attribute exist?)' + bug_reports_message()) -''' -Workaround for issue in urllib.util.ssl_.py: ssl_wrap_context does not pass -server_hostname to SSLContext.wrap_socket if server_hostname is an IP, -however this is an issue because we set check_hostname to True in our SSLContext. - -Monkey-patching IS_SECURETRANSPORT forces ssl_wrap_context to pass server_hostname regardless. - -This has been fixed in urllib3 2.0+. -See: https://github.com/urllib3/urllib3/issues/517 -''' - -if urllib3_version < (2, 0, 0): - with contextlib.suppress(Exception): - urllib3.util.IS_SECURETRANSPORT = urllib3.util.ssl_.IS_SECURETRANSPORT = True - # Requests will not automatically handle no_proxy by default # due to buggy no_proxy handling with proxy dict [1].