Skip to content

Commit

Permalink
Configurable connectionRequestTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
gillarramendi committed Nov 26, 2018
1 parent babd767 commit fc82cf6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public class ProxyServlet extends HttpServlet {

/** A integer parameter name to set the socket read timeout (millis) */
public static final String P_READTIMEOUT = "http.read.timeout";

/** A integer parameter name to set the connection request timeout (millis) */
public static final String P_CONNECTIONREQUESTTIMEOUT = "http.connectionrequest.timeout";

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

//These next 3 are cached here, and should only be referred to in initialization logic. See the
// ATTR_* parameters.
Expand Down Expand Up @@ -182,6 +186,11 @@ public void init() throws ServletException {
if (readTimeoutString != null) {
this.readTimeout = Integer.parseInt(readTimeoutString);
}

String connectionRequestTimeout = getConfigParam(P_CONNECTIONREQUESTTIMEOUT);
if (connectionRequestTimeout != null) {
this.connectionRequestTimeout = Integer.parseInt(connectionRequestTimeout);
}

String useSystemPropertiesString = getConfigParam(P_USESYSTEMPROPERTIES);
if (useSystemPropertiesString != null) {
Expand All @@ -202,6 +211,7 @@ protected RequestConfig buildRequestConfig() {
.setCookieSpec(CookieSpecs.IGNORE_COOKIES) // we handle them in the servlet instead
.setConnectTimeout(connectTimeout)
.setSocketTimeout(readTimeout)
.setConnectionRequestTimeout(connectionRequestTimeout)
.build();
}

Expand Down

0 comments on commit fc82cf6

Please sign in to comment.