Skip to content

Commit

Permalink
reading VM parameter for EV defining proxy URL
Browse files Browse the repository at this point in the history
  • Loading branch information
André Antakli committed Jan 18, 2024
1 parent 4627997 commit 810c759
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -128,13 +131,19 @@ private Object sendRequest() throws HttpResponseException, IOException, SAXExcep
}
}

private CloseableHttpClient getCloseableClient() {
if (System.getProperty("http.proxyHost") == null && System.getProperty("http.proxyPort") == null) {
private CloseableHttpClient getCloseableClient() throws UnknownHostException, MalformedURLException {
if (System.getProperty("http.proxyHost") == null && System.getProperty("http.proxyPort") == null && System.getProperty("http.proxyEV") == null) {
return HttpClientBuilder.create()
.setDefaultRequestConfig(requestConfig)
.setRetryHandler(new DefaultHttpRequestRetryHandler(2, false)).build();
} else {
HttpHost proxyHost = new HttpHost(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort")));
HttpHost proxyHost;
if (System.getProperty("http.proxyHost") == null && System.getProperty("http.proxyPort") == null) {
URL proxyEV = new URL(System.getenv(System.getProperty("http.proxyEV")));
proxyHost = new HttpHost(proxyEV.getHost(), proxyEV.getPort());
} else {
proxyHost = new HttpHost(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort")));
}
LOG.info("Using Proxy: " + proxyHost.toURI());
return HttpClientBuilder.create()
.setDefaultRequestConfig(requestConfig)
Expand Down

0 comments on commit 810c759

Please sign in to comment.