我正在尝试使用http://github.com/rnewman/clj-apache-http开始跑步
(http/get (java.net.URI. url)
:headers {"User-Agent" user-agent}
:parameters (http/map->params
{:default-proxy (http/http-host :host "localhost"
:port 8888)})
:as :string)问题是,我的代理(squid)需要身份验证。我如何将我的用户名/密码“输入”到这个库中?
谢谢!
发布于 2010-03-31 04:56:19
将以下内容添加到我的headers字典中确实起到了作用:
"Proxy-Authorization" (str "Basic "
(base64/encode-str "username:password"))就像Mac说的--这也可以用一个过滤器来实现--但是preemptive-basic-auth-filter不会起作用,因为它发送的是WWW-Authorization的报头,而不是Proxy-Authorization。
发布于 2010-03-30 13:53:57
clj-apache-http有一个可以使用的preemptive-basic-auth-filter。支持"name: password“形式的用户名/密码组合字符串。该函数的用法没有很好的文档记录,但可以在here中找到。示例(未测试):
(http/get (java.net.URI. url)
:headers {"User-Agent" user-agent}
:parameters (http/map->params
{:default-proxy (http/http-host :host "localhost"
:port 8888)})
:as :string
:filters ((preemptive-basic-auth-filter "name:password")))https://stackoverflow.com/questions/2541934
复制相似问题