-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP::Client proxy support #2963
Comments
Would be great to have this in the standard library. Here's how you can implement proxy support meanwhile it makes its way into the standard library:
|
If desperate some shards support it: https://github.com/veelenga/awesome-crystal#http |
#13063 proposes an implementation based on an environment variable for configuring a proxy. My idea would be a property Maybe it could make sense to add a generic environment variable, but this should come as a later enhancement. |
Just as a remark, Google allows setting an HTTP proxy using environment variable, so it's not uncommon: https://pkg.go.dev/golang.org/x/net/http/httpproxy |
Sure. As I mentioned, this is something many programs would want to have. But for a generic HTTP client library, this is not sufficient. It needs to be configurable per client instance. That's why I think the stdlib API should provide that. That's exactly how Golang is doing it: |
In which case, in a server, you would want to use two different proxies? I thought servers were behind a proxy so it kind of makes sense that this is a global configuration. |
Not sure what you're talking about? This is about |
I honestly don't know much about proxies. But if you are in a machine behind a proxy and you need to make an http request, you tell it to use that proxy. Is that more or less how it works? If so, are you usually behind one proxy, or do you need to choose one of several? |
Well yes, that's a common use case that servers outside your local network (for example those on the open internet) are only reachable via proxy. In that case you would probably use a single proxy for all (or most) HTTP requests. |
#13063 Has been updated to work with a proxy property at the class, subclass, and instance level. It looks for the proxy in the following order instance -> subclass (if applicable) -> class -> environment variables (http_proxy, https_proxy, and all_proxy are respected) It should be as customizable as one would need....... |
The current HTTP::Client does not support the ability to use a proxy. And it would certainly be a nice feature to have.
It might be an idea to implement this alongside the HTTP/2.2 support that is planned for some time.
The text was updated successfully, but these errors were encountered: