Currently Got allows use of proxies by configuring agent (https://github.com/sindresorhus/got#proxies).
This approach suffers from the same issues I have described in the issue about logging (#559 (comment)).
tl;dr;
When you have an application which depends on modules that use got, there is no way to enable got proxy without digging through node_modules/ and patching the code.
I have no knowledge of where the HTTP_PROXY convention originates, but it is prevalent practice for the exactly the reason described above – ability to inspect all application traffic without configuring individual HTTP client instances.
"request" package already implements HTTP_PROXY configuration (https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables):
Controlling proxy behaviour using environment variables
The following environment variables are respected by request:
HTTP_PROXY / http_proxy
HTTPS_PROXY / https_proxy
NO_PROXY / no_proxy
When HTTP_PROXY / http_proxy are set, they will be used to proxy non-SSL requests that do not have an explicit proxy configuration option present. Similarly, HTTPS_PROXY / https_proxy will be respected for SSL requests that do not have an explicit proxy configuration option. It is valid to define a proxy in one of the environment variables, but then override it for a specific request, using the proxy configuration option. Furthermore, the proxy configuration option can be > explicitly set to false / null to opt out of proxying altogether for that request.
request is also aware of the NO_PROXY/no_proxy environment variables. These variables provide a granular way to opt out of proxying, on a per-host basis. It should contain a comma separated list of hosts to opt out of proxying. It is also possible to opt of proxying when a particular destination port is used. Finally, the variable may be set to * to opt out of the implicit proxy configuration of the other environment variables.
Here's some examples of valid no_proxy values:
google.com - don't proxy HTTP/HTTPS requests to Google.
google.com:443 - don't proxy HTTPS requests to Google, but do proxy HTTP requests to Google.
google.com:443, yahoo.com:80 - don't proxy HTTPS requests to Google, and don't proxy HTTP requests to Yahoo!
* - ignore https_proxy/http_proxy environment variables altogether.
I suggest that got implement equivalent logic.
agent configuration should remain and it should override HTTP_PROXY setting (it then becomes the responsibility of the HTTP agent to respect the environment variables).
Currently Got allows use of proxies by configuring
agent(https://github.com/sindresorhus/got#proxies).This approach suffers from the same issues I have described in the issue about logging (#559 (comment)).
tl;dr;
When you have an application which depends on modules that use got, there is no way to enable got proxy without digging through node_modules/ and patching the code.
I have no knowledge of where the HTTP_PROXY convention originates, but it is prevalent practice for the exactly the reason described above – ability to inspect all application traffic without configuring individual HTTP client instances.
"request" package already implements HTTP_PROXY configuration (https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables):
I suggest that got implement equivalent logic.
agentconfiguration should remain and it should overrideHTTP_PROXYsetting (it then becomes the responsibility of the HTTP agent to respect the environment variables).