Skip to content

Commit

Permalink
Use plain http proxy for http request, not tunneling
Browse files Browse the repository at this point in the history
  • Loading branch information
perklet committed Jun 25, 2024
1 parent d1df074 commit d1a64ff
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions curl_cffi/requests/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,21 @@ def _set_curl_options(
)

if proxy is not None:
if parts.scheme == "https" and proxy.startswith("https://"):
warnings.warn(
"You may be using http proxy WRONG, the prefix should be 'http://' not 'https://',"
"see: https://github.com/yifeikong/curl_cffi/issues/6",
RuntimeWarning,
stacklevel=2,
)

c.setopt(CurlOpt.PROXY, proxy)
# for http proxy, need to tell curl to enable tunneling
if not proxy.startswith("socks"):
c.setopt(CurlOpt.HTTPPROXYTUNNEL, 1)

if parts.scheme == "https":
if proxy.startswith("https://"):
warnings.warn(
"Make sure you are using https over https proxy, otherwise, "
"the proxy prefix should be 'http://' not 'https://', "
"see: https://github.com/yifeikong/curl_cffi/issues/6",
RuntimeWarning,
stacklevel=2,
)
# For https site with http tunnel proxy, tell curl to enable tunneling
if not proxy.startswith("socks"):
c.setopt(CurlOpt.HTTPPROXYTUNNEL, 1)

# proxy_auth
proxy_auth = proxy_auth or self.proxy_auth
Expand Down

0 comments on commit d1a64ff

Please sign in to comment.