aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-03-31 16:44:08 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2020-04-02 11:50:25 +0200
commit2276d93f0487e6f5c2aa653abdb84d5ab82d082e (patch)
treed20a7671e507b3f1f35c64e673f27e89cbf34479 /jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server
parent735927b28507fa3d2ae0cd2b671ba4d10ff9b666 (diff)
Add connector config for max connection life
Diffstat (limited to 'jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server')
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
index d8a3f8944ec..b9d686c1d6b 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.time.Instant;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
@@ -152,6 +153,14 @@ class HttpRequestDispatch {
connection.getGenerator().setPersistent(false);
}
}
+ double maxConnectionLifeInSeconds = connectorConfig.maxConnectionLife();
+ if (maxConnectionLifeInSeconds > 0) {
+ HttpConnection connection = getConnection(request);
+ Instant expireAt = Instant.ofEpochMilli((long)(connection.getCreatedTimeStamp() + maxConnectionLifeInSeconds * 1000));
+ if (Instant.now().isAfter(expireAt)) {
+ connection.getGenerator().setPersistent(false);
+ }
+ }
}
@SafeVarargs