Skip to content

Instantly share code, notes, and snippets.

@omernaci
Created August 2, 2018 12:33
Show Gist options
  • Save omernaci/9da23ec0a672e7a3590156ddd94799b5 to your computer and use it in GitHub Desktop.
Save omernaci/9da23ec0a672e7a3590156ddd94799b5 to your computer and use it in GitHub Desktop.
Apache HttpComponents Proxy Config(v4.5.5)
try (ClosableHttpClient httpClient = HttpClients.createDefault()) {
HttpHost proxy = new HttpHost("proxy host", 3128);
RequestConfig config = RequestConfig.custom()
.setProxy(proxy)
.build();
HttpGet httpget = new HttpGet("/path");
httpget.setConfig(config);
...
...
System.out.println("Executing request " + httpget.getRequestLine() + " to " + target + " via " + proxy);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment