Skip to content

Commit fc82cf6

Browse files
committed
Configurable connectionRequestTimeout
1 parent babd767 commit fc82cf6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public class ProxyServlet extends HttpServlet {
9191

9292
/** A integer parameter name to set the socket read timeout (millis) */
9393
public static final String P_READTIMEOUT = "http.read.timeout";
94+
95+
/** A integer parameter name to set the connection request timeout (millis) */
96+
public static final String P_CONNECTIONREQUESTTIMEOUT = "http.connectionrequest.timeout";
9497

9598
/** A boolean parameter whether to use JVM-defined system properties to configure various networking aspects. */
9699
public static final String P_USESYSTEMPROPERTIES = "useSystemProperties";
@@ -114,6 +117,7 @@ public class ProxyServlet extends HttpServlet {
114117
protected boolean useSystemProperties = true;
115118
protected int connectTimeout = -1;
116119
protected int readTimeout = -1;
120+
protected int connectionRequestTimeout = -1;
117121

118122
//These next 3 are cached here, and should only be referred to in initialization logic. See the
119123
// ATTR_* parameters.
@@ -182,6 +186,11 @@ public void init() throws ServletException {
182186
if (readTimeoutString != null) {
183187
this.readTimeout = Integer.parseInt(readTimeoutString);
184188
}
189+
190+
String connectionRequestTimeout = getConfigParam(P_CONNECTIONREQUESTTIMEOUT);
191+
if (connectionRequestTimeout != null) {
192+
this.connectionRequestTimeout = Integer.parseInt(connectionRequestTimeout);
193+
}
185194

186195
String useSystemPropertiesString = getConfigParam(P_USESYSTEMPROPERTIES);
187196
if (useSystemPropertiesString != null) {
@@ -202,6 +211,7 @@ protected RequestConfig buildRequestConfig() {
202211
.setCookieSpec(CookieSpecs.IGNORE_COOKIES) // we handle them in the servlet instead
203212
.setConnectTimeout(connectTimeout)
204213
.setSocketTimeout(readTimeout)
214+
.setConnectionRequestTimeout(connectionRequestTimeout)
205215
.build();
206216
}
207217

0 commit comments

Comments
 (0)