Fad*_*enB 6 authentication proxy curl polipo
我正在尝试下载通过基本身份验证保护的文件:
curl "http://User:Pass@example.com/blub/bla.bin"
Run Code Online (Sandbox Code Playgroud)
这工作正常。
一旦我告诉 curl 使用我本地安装的 polipo 它就会失败:
$ http_proxy="http://127.0.0.1:8123" curl "http://XXXXX:Pass@example.com/blub/bla.bin"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Proxy error: 504 Host XXXXX lookup failed: Host not found.</title>
</head><body>
<h1>504 Host XXXXX lookup failed: Host not found</h1>
<p>The following error occurred while trying to access <strong>http://XXXXX:Pass@example.com/blub/bla.bin</strong>:<br><br>
<strong>504 Host XXXXX lookup failed: Host not found</strong></p>
<hr>Generated Wed, 12 Mar 2014 22:46:10 CET by Polipo on <em>hostname:8123</em>.
</body></html>
$
Run Code Online (Sandbox Code Playgroud)
这是由于 Polipo 或 curl 中的错误引起的吗?(还是我做错了?)
编辑:http_proxy="http://127.0.0.1:8123" curl -u XXXXX:Pass "http://example.com/blub/bla.bin"
工作正常。谢谢!
Bab*_*aba 11
没有必要使用http_proxy
,试试这个:
curl -x PROXY-SERVER:PORT -U USER:PASS URL
Run Code Online (Sandbox Code Playgroud)
curl -x 127.0.0.1:8123 -U XXXXX:Pass "http://example.com/blub/bla.bin"
经过更多挖掘后,我自己找到了答案:
http://curl.haxx.se/docs/manual.html指出
笔记!根据 URL 规范,HTTP URL 不能包含用户和密码,因此当通过代理使用curl 时,该样式将不起作用,即使curl 在其他时候允许。使用代理时,必须对用户和密码使用 -u 样式。
所以我的做法是错误的:)