Generic way to set a proxy server for a JaxRs client

637 Views Asked by At

I have code where the the webtarget is passed to me from a different library. I do not have access to the code to modify the ResteasyClient. What I am trying to do is the equivalent of

   Client client = new ResteasyClientBuilderImpl()
                   .defaultProxy("127.0.0.1", 9999, "http")
                    .build(); 

I already tried -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=9999

I also tried

System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "9999");
System.setProperty("java.net.useSystemProxies", "true");`

Neither one does the equivalent of defaultProxy("127.0.0.1", 9999, "http")

Seems like they might have a solution over here. I tried signing up to see the solution. But they have no easy way subscribe where I can just punch in my credit card number.

I guess another way to ask this question would be, is there a way, where I can set all instances of org.apache.http.client.config.RequestConfig have its proxy property set to http://127.0.0.1:9999

Additional details: What I am trying to do is to route http traffic thru a proxy server. I don't want to modify anything at the OS level (traffic shaping stuff). If I use a regular http client in java the parameters -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=9999 work. But when using jboss resteasy client those parameters do not work.

0

There are 0 best solutions below