From 4a4cf9ce5867d29b4557a0b28eca7a56e77207de Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E4=BE=9D=E4=BA=91?= Date: Tue, 28 Jul 2020 22:09:45 +0800 Subject: [PATCH] curl_httpclient: set CURLOPT_PROXY to NULL if pycurl supports it This restores curl's default behaviour: use environment variables. This option was set to "" to disable proxy in 905a215a286041c986005859c378c0445c127cbb but curl uses environment variables by default. --- tornado/curl_httpclient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 3ed82b765..161941842 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -406,7 +406,10 @@ class CurlAsyncHTTPClient(AsyncHTTPClient): "Unsupported proxy_auth_mode %s" % request.proxy_auth_mode ) else: - curl.setopt(pycurl.PROXY, "") + try: + curl.unsetopt(pycurl.PROXY) + except TypeError: # not supported, disable proxy + curl.setopt(pycurl.PROXY, "") curl.unsetopt(pycurl.PROXYUSERPWD) if request.validate_cert: curl.setopt(pycurl.SSL_VERIFYPEER, 1) -- 2.47.2