1
我尝试了2个小时,无法使其工作。 这是我做过什么:如何在使用身份验证的代理服务器后面使用HTTPBuilder
grails add-proxy myproxy "--host=<host>" "--port=<port>" "--username=<username>" "--password=<psw>" grails use-proxy myproxy
我拒绝连接错误,指的是代理工作不
在我的常规文件,我添加代理
def http = new HTTPBuilder("http://http://headers.jsontest.com/") http.setProxy(host, port, "http"); http.request(Method.GET, JSON) { uri.path = '/' response.success = { resp, json -> ..... } }
然后我得到groovyx.net.http.HttpResponseException:需要代理验证
我无法弄清楚如何设置用户/ PSW的代理,使其工作
我试图Java的方式,而不是工作
System.setProperty("http.proxyUser", username);
System.setProperty("http.proxyPassword", password);
和
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, .toCharArray());
}});
有谁知道如何做到这一点?
感谢,但是这是行不通的,我想这需要某事像setProxyCredentials代替。但是,我无法弄清楚API。 – user2644762