2010-11-06 139 views
6

我想用一个oneliner做一个帖子(在这种情况下是twitter)。通过验证的代理和验证的http资源卷曲

如果我没有代理

curl -u user:pass -d status="message" http://twitter.com/statuses/update.xml 

完美。

但是,当我在身份验证的代理后面它不。

我tryied:

curl -X proxy:port -U proxyUser:proxyPass -u user:pass -d status="message" http://twitter.com/statuses/update.xml 

那它跳到我与

代理不支持基本身份验证

那么,你知道我做错了什么?

在此先感谢。

回答

2

尝试添加--proxy-digest--proxy-anyauth。 我想连接到代理服务器,应该使用小写-x(而不是-X)。

4

您可以将用户名/密码放在已验证资源的URL中,以避免出现额外的命令行复杂性。

http://username:[email protected]/statuses/update.xml 

此外,--proxy快捷键是一个小写的x,正如cababunga指出的那样。

curl -x proxyaddr:port -U proxyUser:proxyPass -u user:pass -d status="message" http://twitter.com/statuses/update.xml 
14

Cababunga的回答是正确的,但他们错过了另一种选择:--proxy-ntlm。有些代理不会使用--proxy-anyauth正确授权,所以理想情况下您需要指定代理使用的身份验证方法。如果您运行curl -v -U user:pass -x proxy:port --url http://www.google.com,你应该遵循以下线的东西:

  • 关于连接()来代理[代理]端口[你的端口(#0)
  • 试图[IP]。 ..
  • 连接
  • 连接到[代理]([IP])端口[你的端口(#0)
  • 使用建立HTTP代理隧道www.google.com:443
  • 代理AUTH基本与用户'[用户]'
  • CONNECT www.google.com:443 HTTP/1.1
  • 主机:www.google.com:443
  • 代理授权:基本[乱码]
  • 的User-Agent:卷曲/ [版本]([OS ])libcurl/[ver] OpenSSL/[ver] zlib/[ver]
  • 代理连接:保持活动
  • HTTP/1。1 407需要代理身份验证
  • 代理身份验证:协商
  • 代理验证:NTLM

添加任何你的代理服务器进行身份验证参数看到国旗,你应该是好去。在本例中,您将添加--proxy-ntlm标志。

0

我设法与米卡的答案的帮助在这里执行此:

这是我在最后得到了命令访问到位桶回购:

curl -u userBitbucket:PwdBitBucket -U userProxy:pwdProxy -x address_proxy:port:proxy --proxy-ntlm http://host:port/projects/project/repos/repo/browse/file