wojtekmach / req

Req is a batteries-included HTTP client for Elixir.
https://hexdocs.pm/req
Apache License 2.0
1.09k stars 117 forks source link

Support http_proxy and https_proxy environment variables #394

Open gmile opened 3 months ago

gmile commented 3 months ago

It would be great if Req supported reading http_proxy and https_proxy environment variables out of the box. A use case I have in mind is being able to debug HTTP interaction in programs that use Req as an HTTP client. For example, via tools like mitmproxy.

In my own programs, I can use proxy settings introduced in https://github.com/wojtekmach/req/pull/149 or even go as far as to use System.get_env to optionally read http_proxy and https_proxy ENV vars. However, for packages that rely on Req this may be much harder and requi modification of the package's source code (unless I am missing something, of course).

P.S. I am not sure if this is the right place to file an issue, or if it should be Finch 🙈 Mint issue tracker would not the right place, it seems (based on https://github.com/elixir-mint/mint/issues/92)

wojtekmach commented 2 months ago

Yes, PRs appreciated!

I think we should support http_proxy env var out of the box but also have an :http_proxy option that can be set with the same value. (Same goes for https.) WDYT?

This recently came up with https://elixirforum.com/t/making-a-req-request-with-proxy/65771/2.