Mih*_*hai 46 http-proxy environment-variables
http_proxy和都遇到过HTTP_PROXY。两种形式是等价的吗?它们中的一个是否优先于另一个?
Gil*_*il' 41
在应用程序可以使用环境变量之前,没有中央机构为环境变量分配官方含义。POSIX定义了一些变量 ( PATH, TERM, ...)的含义,并以非规范的方式列出了一些常用的变量,所有这些变量都是大写的。http_proxy而朋友不是其中之一。
与许多应用程序使用的基本上所有常规环境变量不同http_proxy,https_proxy、ftp_proxy和no_proxy通常都是小写的。我不记得有任何只能理解大写字母的程序,我什至找不到一个尝试大写字母的程序。许多程序只使用小写变量,包括 lynx、wget、curl、perl LWP、perl WWW::Search、python urllib/urllib2 等。因此对于这些变量,正确的形式是小写形式。
小写名称至少可以追溯到1994 年 3 月的CERN libwww 2.15(感谢 Stéphane Chazelas 找到它)。我不知道是什么促使选择小写字母,即使在那时这也是不寻常的。
lak*_*tak 16
没有标准,根据应用程序使用大写和小写版本(另请参阅 HTTPS_PROXY、ALL_PROXY、NO_PROXY)。
例如:
卷曲
ENVIRONMENT VARIABLES
Curl reads and understands the following environment variables:
http_proxy, HTTPS_PROXY, FTP_PROXY
They should be set for protocol-specific proxies. General proxy should be
set with
ALL_PROXY
A comma-separated list of host names that shouldn't go through any proxy is
set in (only an asterisk, '*' matches all hosts)
NO_PROXY
Run Code Online (Sandbox Code Playgroud)
混帐
http.proxy
Override the HTTP proxy, normally configured using the http_proxy, https_proxy,
and all_proxy environment variables (see curl(1)). [..]
Run Code Online (Sandbox Code Playgroud)
Python
urllib.request.getproxies() 支持小写和大写变体。
它还提到了一个安全问题:
如果设置了环境变量 REQUEST_METHOD,这通常表明您的脚本在 CGI 环境中运行,则环境变量 HTTP_PROXY(大写 _PROXY)将被忽略。这是因为该变量可以由客户端使用“Proxy:”HTTP 标头注入。如果您需要在 CGI 环境中使用 HTTP 代理,请显式使用 ProxyHandler,或确保变量名称为小写(或至少是 _proxy 后缀)。
某些应用程序允许NO_PROXY包含星号/ip 范围,而其他应用程序则不允许。
所以
export https_proxy=$http_proxy HTTP_PROXY=$http_proxy HTTPS_PROXY=$http_proxy NO_PROXY=$no_proxy
Run Code Online (Sandbox Code Playgroud)
应该有你。