|
36 | 36 | import org.apache.commons.lang3.StringUtils; |
37 | 37 | import org.apache.http.Header; |
38 | 38 | import org.apache.http.HttpEntity; |
| 39 | +import org.apache.http.HttpHost; |
39 | 40 | import org.apache.http.HttpResponse; |
40 | 41 | import org.apache.http.HttpStatus; |
41 | 42 | import org.apache.http.StatusLine; |
@@ -91,6 +92,8 @@ public class ServerConnection implements Connector { |
91 | 92 | public static final String EXECUTE_TYPE_PROPERTY = "executeType"; |
92 | 93 | public static final String OPERATION_PROPERTY = "operation"; |
93 | 94 | public static final String CUSTOM_HEADERS_PROPERTY = "customHeaders"; |
| 95 | + private static final String PROXY_HOST_PROPERTY = "engine.http.proxyHost"; |
| 96 | + private static final String PROXY_PORT_PROPERTY = "engine.http.proxyPort"; |
94 | 97 |
|
95 | 98 | private static final int CONNECT_TIMEOUT = 10000; |
96 | 99 | private static final int IDLE_TIMEOUT = 300000; |
@@ -134,7 +137,21 @@ public ServerConnection(int timeout, String[] httpsProtocols, String[] httpsCiph |
134 | 137 |
|
135 | 138 | cookieStore = new BasicCookieStore(); |
136 | 139 | socketConfig = SocketConfig.custom().setSoTimeout(timeout).build(); |
137 | | - requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(timeout).build(); |
| 140 | + |
| 141 | + RequestConfig.Builder requestConfigBuilder = RequestConfig.custom() |
| 142 | + .setConnectTimeout(CONNECT_TIMEOUT) |
| 143 | + .setSocketTimeout(timeout); |
| 144 | + |
| 145 | + // If HTTP Proxy is set, configure it |
| 146 | + String httpProxyHost = System.getProperty(PROXY_HOST_PROPERTY); |
| 147 | + if (allowHTTP && StringUtils.isNotBlank(httpProxyHost)) { |
| 148 | + String httpProxyPort = System.getProperty(PROXY_PORT_PROPERTY); |
| 149 | + int proxyPort = StringUtils.isNotBlank(httpProxyPort) ? Integer.parseInt(httpProxyPort) : 8888; |
| 150 | + logger.info("Using API HTTP Proxy {}:{}", httpProxyHost, proxyPort); |
| 151 | + requestConfigBuilder.setProxy(new HttpHost(httpProxyHost, proxyPort)); |
| 152 | + } |
| 153 | + |
| 154 | + requestConfig = requestConfigBuilder.build(); |
138 | 155 | keepAliveStrategy = new CustomKeepAliveStrategy(); |
139 | 156 |
|
140 | 157 | createClient(); |
|
0 commit comments