mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-06 00:13:17 +00:00
[rh:curl_cffi] Fix HTTPS proxy support
This commit is contained in:
parent
b44e0f8b98
commit
e565e45a6f
|
@ -21,7 +21,7 @@
|
||||||
TransportError,
|
TransportError,
|
||||||
)
|
)
|
||||||
from .impersonate import ImpersonateRequestHandler, ImpersonateTarget
|
from .impersonate import ImpersonateRequestHandler, ImpersonateTarget
|
||||||
from ..dependencies import curl_cffi
|
from ..dependencies import curl_cffi, certifi
|
||||||
from ..utils import int_or_none
|
from ..utils import int_or_none
|
||||||
|
|
||||||
if curl_cffi is None:
|
if curl_cffi is None:
|
||||||
|
@ -156,6 +156,13 @@ def _send(self, request: Request):
|
||||||
# See: https://curl.se/libcurl/c/CURLOPT_HTTPPROXYTUNNEL.html
|
# See: https://curl.se/libcurl/c/CURLOPT_HTTPPROXYTUNNEL.html
|
||||||
session.curl.setopt(CurlOpt.HTTPPROXYTUNNEL, 1)
|
session.curl.setopt(CurlOpt.HTTPPROXYTUNNEL, 1)
|
||||||
|
|
||||||
|
# curl_cffi does not currently set these for proxies
|
||||||
|
session.curl.setopt(CurlOpt.PROXY_CAINFO, certifi.where())
|
||||||
|
|
||||||
|
if not self.verify:
|
||||||
|
session.curl.setopt(CurlOpt.PROXY_SSL_VERIFYPEER, 0)
|
||||||
|
session.curl.setopt(CurlOpt.PROXY_SSL_VERIFYHOST, 0)
|
||||||
|
|
||||||
headers = self._get_impersonate_headers(request)
|
headers = self._get_impersonate_headers(request)
|
||||||
|
|
||||||
if self._client_cert:
|
if self._client_cert:
|
||||||
|
@ -203,7 +210,10 @@ def _send(self, request: Request):
|
||||||
max_redirects_exceeded = True
|
max_redirects_exceeded = True
|
||||||
curl_response = e.response
|
curl_response = e.response
|
||||||
|
|
||||||
elif e.code == CurlECode.PROXY:
|
elif (
|
||||||
|
e.code == CurlECode.PROXY
|
||||||
|
or (e.code == CurlECode.RECV_ERROR and 'Received HTTP code 407 from proxy after CONNECT' in str(e))
|
||||||
|
):
|
||||||
raise ProxyError(cause=e) from e
|
raise ProxyError(cause=e) from e
|
||||||
else:
|
else:
|
||||||
raise TransportError(cause=e) from e
|
raise TransportError(cause=e) from e
|
||||||
|
|
Loading…
Reference in a new issue