I need to go through a proxy to get to my target server. It seems that I can do it with code like this:
def http = new HTTPBuilder( 'http://www.somesite.com')
http.setProxy('proxy.com', 8080, 'http')
but not like this:
System.setProperty("http.proxyHost", "proxy.com");
System.setProperty("http.proxyPort", "8080");
def http = new HTTPBuilder( 'http://www.somesite.com')
Shouldn't this work?
The real problem is that I'm using HTTPBuilder
from within a Grails application and was expecting that starting Tomcat using -Dhttp.proxyHost
and -Dhttp.proxyPort
would let HTTPBuilder
go through the proxy... but it is like HTTPBuilder
is ignoring those JVM parameters.
It looks like the httpclient
can be configured to use the JVM parameters like this: client.getHostConfiguration().setProxy(host, port)
(from this stackoverflow question). Can this be done in HTTPBuilder
(I don't know how to reference the underlaying httpclient
)?