Configuring web-requests to use a proxy
See original GitHub issueI think there is something preventing CurlAsyncHTTPClient from accepting defaults.
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient", defaults=defaults)
didn’t work from config.yaml.
I had to do this hack:
extraConfig: |
import pycurl
from tornado.httpclient import HTTPRequest
def configure_proxy(curl):
logging.error(curl.getinfo(pycurl.EFFECTIVE_URL))
# we only want google oauth to use the proxy
if "google" in curl.getinfo(pycurl.EFFECTIVE_URL):
logging.error("adding proxy")
curl.setopt(pycurl.PROXY, "proxy.example.com")
curl.setopt(pycurl.PROXYPORT, 8080)
# never do this
HTTPRequest._DEFAULTS['prepare_curl_callback'] = configure_proxy
I don’t know why this doesn’t work:
import certifi
from tornado.httpclient import AsyncHTTPClient
defaults2 = dict(ca_certs=certifi.where())
defaults2['proxy_host'] = 'proxy.example.com'
defaults2['proxy_port'] = 8080
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient", defaults=defaults2)
Actually, I do have one guess. Maybe this overwrite the defaults?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
WebRequest.Proxy Property (System.Net) | Microsoft Learn
The Proxy property identifies the network proxy that the request uses to access the Internet resource. The request is made through the proxy...
Read more >How to use PowerShell Invoke-WebRequest behind corporate ...
Let's see how you can set proxy for Invoke-WebRequest for example. Other commands usually support proxy settings similarly.
Read more >C# Connecting Through Proxy - Stack Overflow
config. This sets a default proxy that all http requests will use. Depending upon exactly what you need to achieve, you may or...
Read more >Send web requests through an upstream proxy in WAN
Configure Sophos Firewall to use the upstream proxy in WAN. In this example, the upstream proxy is in the WAN zone. The network...
Read more >Enabling HTTP proxy for .NET webservice client
You can start tweaking your Web.config file to set this proxy the right way, ... Proxy = WebRequest.DefaultWebProxy; request.Proxy.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this feels much like hacking…
seems that the issue is with tornado that doesn’t respect http_proxy environment variable for CurlAsyncHttpClient: https://github.com/tornadoweb/tornado/issues/754
The conclusion for the tornado issue is:
Even for simple_httpclient i don’t know if it supports no_proxy
😦
looks like hacking into pycurl is the only solution for now…
Hi. Would be so cool if everybody simply respected the “http_proxy” environment variables…
Here is my hack to make the hub happy with our proxy (our Gitlab instance is behind our proxy). It also support no_proxy with “*”, so that we can have finer proxy tuning: