Skip to content

Instantly share code, notes, and snippets.

@nherbaut
Created September 8, 2015 08:10
Show Gist options
  • Select an option

  • Save nherbaut/20b4ae6af5765f11681e to your computer and use it in GitHub Desktop.

Select an option

Save nherbaut/20b4ae6af5765f11681e to your computer and use it in GitHub Desktop.
http proxy jersey
package test;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.JerseyClientBuilder;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
ClientConfig cc = new ClientConfig();
//cc.property(ClientProperties.PROXY_URI, "http://localhost:8080");
Client client = JerseyClientBuilder.newBuilder().withConfig(cc).build();
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8080");
Response r = client.target("http://google.fr").request().get();
System.out.println(r.getStatus());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment