cpanm如何检索需要用户名和密码的代理的设置



我正在与CPNM合作,以与需要用户名和密码的代理进行交互。我在运行"o conf init/proxy/under cpan"时指定了设置。我的看法是,在unix环境中用于指定代理的变量并不是整个环境中的标准变量。在将环境变量设置为正确的值后,其他unix实用程序通过代理正确工作。

我的问题如下:

  1. CPNM如何与任何环境变量接口?它们会是什么?

  2. 是否有相关的代码区域可以帮助我们消除歧义,我认为CPANM内部有LWP接口?https://github.com/miyagawa/cpanminus/blob/devel/App-cpanminus/cpanm

####:/mnt/c/Projects$ sudo cpanm install Catalyst::Helper -v
cpanm (App::cpanminus) 1.7040 on perl 5.022001 built for x86_64-linux-gnu-thread-multi
Work directory is /home/####/.cpanm/work/1543605706.124
You have make /usr/bin/make
You have LWP 6.36
You have /bin/tar: tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
Searching install () on cpanmetadb ...
########:/mnt/c/Projects$ env | grep HTTP_proxy
HTTP_proxy=http://####:###

据我所见,cpanm(实际上App::Cpanminus依赖HTTP::Tiny来运行HTTP请求。

来自HTTP::Tiny:的文档

HTTP::Tiny可以代理HTTP和https请求。仅支持基本代理授权,并且必须将其作为代理URL的一部分提供:http://user:pass@proxy.example.com/.

HTTP::Tiny支持以下代理环境变量:HTTP_proxy或HTTP_proxy、https_proxy或https_proxy、all_proxy和all_proxy

因此,您应该尝试将代理用户名和密码指定为url的一部分,如:

$ export HTTP_PROXY=http://<user>:<password>@<url>:<port>
$ export HTTPS_PROXY=http://<user>:<password>@<url>:<port>

此外,根据文档,HTTP_PROXY设置由LWP::UserAgent(cpan命令行实用程序使用的主要HTTP客户端(接受,而HTTPS_PROXY由curl支持(LWP失败时cpan的回退(。请参阅LWP::UserAgent文档和curl文档。

因此HTTP_PROXY/HTTPS_PROXY应该是所有CPAN客户端都支持的公共环境变量。

最新更新