|
38 | 38 | import org.apache.commons.cli.ParseException;
|
39 | 39 | import org.apache.commons.lang.time.StopWatch;
|
40 | 40 | import org.apache.http.HttpEntity;
|
| 41 | +import org.apache.http.HttpHost; |
41 | 42 | import org.apache.http.client.methods.CloseableHttpResponse;
|
42 | 43 | import org.apache.http.client.methods.HttpPost;
|
43 | 44 | import org.apache.http.client.methods.HttpUriRequest;
|
|
62 | 63 | @Mojo(name = "run-crawler", requiresProject = false, defaultPhase = LifecyclePhase.COMPILE)
|
63 | 64 | public class BenchmarkCrawler extends AbstractMojo {
|
64 | 65 |
|
| 66 | + public static String proxyHost, proxyPort; |
| 67 | + |
65 | 68 | @Parameter(property = "crawlerFile")
|
66 | 69 | String pluginFilenameParam;
|
67 | 70 |
|
@@ -191,9 +194,22 @@ static CloseableHttpClient createAcceptSelfSignedCertificateClient()
|
191 | 194 | SSLConnectionSocketFactory connectionFactory =
|
192 | 195 | new SSLConnectionSocketFactory(sslContext, allowAllHosts);
|
193 | 196 |
|
194 |
| - // finally create the HttpClient using HttpClient factory methods and assign the SSL Socket |
195 |
| - // Factory |
196 |
| - return HttpClients.custom().setSSLSocketFactory(connectionFactory).build(); |
| 197 | + // Set Proxy settings |
| 198 | + HttpHost httpHost = null; |
| 199 | + if ((proxyHost = System.getProperty("proxyHost")) != null |
| 200 | + && (proxyPort = System.getProperty("proxyPort")) != null) { |
| 201 | + httpHost = new HttpHost(proxyHost, Integer.parseInt(proxyPort)); |
| 202 | + // finally create the HttpClient using HttpClient factory methods and assign the SSL |
| 203 | + // Socket Factory and assign the setProxy |
| 204 | + return HttpClients.custom() |
| 205 | + .setSSLSocketFactory(connectionFactory) |
| 206 | + .setProxy(httpHost) |
| 207 | + .build(); |
| 208 | + } else { |
| 209 | + // finally create the HttpClient using HttpClient factory methods and assign the SSL |
| 210 | + // Socket Factory |
| 211 | + return HttpClients.custom().setSSLSocketFactory(connectionFactory).build(); |
| 212 | + } |
197 | 213 | }
|
198 | 214 |
|
199 | 215 | /**
|
|
0 commit comments