Created
September 8, 2015 08:10
-
-
Save nherbaut/20b4ae6af5765f11681e to your computer and use it in GitHub Desktop.
http proxy jersey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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