I tried 2 hours and could not make it work. This is what I did:
grails add-proxy myproxy "--host=<host>" "--port=<port>" "--username=<username>" "--password=<psw>" grails use-proxy myproxy
I got connection refused error which mean the proxy is not working
In my groovy file, I add the proxy
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 -> ..... } }
I then get groovyx.net.http.HttpResponseException: Proxy Authentication Required
I could not figure out how I set the user/psw for the proxy to make it work
I tried the java way, not working
System.setProperty("http.proxyUser", username);
System.setProperty("http.proxyPassword", password);
and
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, .toCharArray());
}});
Does anyone know how to do this?