mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-15 08:58:28 +00:00
[rh:requests] Remove workarounds for urllib3<2.0.0
Authored by: bashonly
This commit is contained in:
parent
9134400596
commit
bc1370c165
@ -1,6 +1,5 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import contextlib
|
|
||||||
import functools
|
import functools
|
||||||
import http.client
|
import http.client
|
||||||
import logging
|
import logging
|
||||||
@ -101,28 +100,11 @@ def subn(self, repl, string, *args, **kwargs):
|
|||||||
# https://github.com/urllib3/urllib3/commit/a2697e7c6b275f05879b60f593c5854a816489f0
|
# https://github.com/urllib3/urllib3/commit/a2697e7c6b275f05879b60f593c5854a816489f0
|
||||||
import urllib3.util.url
|
import urllib3.util.url
|
||||||
|
|
||||||
if hasattr(urllib3.util.url, 'PERCENT_RE'):
|
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)
|
|
||||||
elif hasattr(urllib3.util.url, '_PERCENT_RE'): # urllib3 >= 2.0.0
|
|
||||||
urllib3.util.url._PERCENT_RE = Urllib3PercentREOverride(urllib3.util.url._PERCENT_RE)
|
urllib3.util.url._PERCENT_RE = Urllib3PercentREOverride(urllib3.util.url._PERCENT_RE)
|
||||||
else:
|
else:
|
||||||
warnings.warn('Failed to patch PERCENT_RE in urllib3 (does the attribute exist?)' + bug_reports_message())
|
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
|
# Requests will not automatically handle no_proxy by default
|
||||||
# due to buggy no_proxy handling with proxy dict [1].
|
# due to buggy no_proxy handling with proxy dict [1].
|
||||||
|
Loading…
Reference in New Issue
Block a user