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