Commit 19942193 authored by Andy Wilkinson's avatar Andy Wilkinson

Polish "Add config props for keep-alive timeout and max keep-alive reqs"

See gh-25815
parent 34b94d88
...@@ -372,18 +372,15 @@ public class ServerProperties { ...@@ -372,18 +372,15 @@ public class ServerProperties {
private int processorCache = 200; private int processorCache = 200;
/** /**
* The number of milliseconds this Connector will wait for another HTTP request * Time to wait for another HTTP request before the connection is closed. When not
* before closing the connection. The default value is to use the value that has * set the connectionTimeout is used. When set to -1 there will be no timeout.
* been set for the connectionTimeout attribute. Use a value of -1 to indicate no
* (i.e. infinite) timeout.
*/ */
private Duration keepAliveTimeout; private Duration keepAliveTimeout;
/** /**
* The maximum number of HTTP requests which can be pipelined until the connection * Maximum number of HTTP requests that can be pipelined before the connection is
* is closed by the server./ Setting this attribute to 1 will disable HTTP/1.0 * closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to
* keep-alive as well as HTTP/1.1 keep-alive and pipelining. Setting this to -1 * -1, an unlimited number of pipelined or keep-alive requests is allowed.
* will allow an unlimited amount of pipelined or keep-alive HTTP requests.
*/ */
private int maxKeepAliveRequests = 100; private int maxKeepAliveRequests = 100;
......
...@@ -233,6 +233,12 @@ class ServerPropertiesTests { ...@@ -233,6 +233,12 @@ class ServerPropertiesTests {
@Test @Test
void customizeMaxKeepAliveRequests() { void customizeMaxKeepAliveRequests() {
bind("server.tomcat.max-keep-alive-requests", "200");
assertThat(this.properties.getTomcat().getMaxKeepAliveRequests()).isEqualTo(200);
}
@Test
void customizeMaxKeepAliveRequestsWithInfinite() {
bind("server.tomcat.max-keep-alive-requests", "-1"); bind("server.tomcat.max-keep-alive-requests", "-1");
assertThat(this.properties.getTomcat().getMaxKeepAliveRequests()).isEqualTo(-1); assertThat(this.properties.getTomcat().getMaxKeepAliveRequests()).isEqualTo(-1);
} }
......
...@@ -99,7 +99,7 @@ class TomcatWebServerFactoryCustomizerTests { ...@@ -99,7 +99,7 @@ class TomcatWebServerFactoryCustomizerTests {
} }
@Test @Test
void customizeKeepAliveTimeout() { void customKeepAliveTimeout() {
bind("server.tomcat.keep-alive-timeout=30ms"); bind("server.tomcat.keep-alive-timeout=30ms");
customizeAndRunServer((server) -> assertThat( customizeAndRunServer((server) -> assertThat(
((AbstractProtocol<?>) server.getTomcat().getConnector().getProtocolHandler()).getKeepAliveTimeout()) ((AbstractProtocol<?>) server.getTomcat().getConnector().getProtocolHandler()).getKeepAliveTimeout())
...@@ -107,7 +107,7 @@ class TomcatWebServerFactoryCustomizerTests { ...@@ -107,7 +107,7 @@ class TomcatWebServerFactoryCustomizerTests {
} }
@Test @Test
void customizeMaxKeepAliveRequests() { void customMaxKeepAliveRequests() {
bind("server.tomcat.max-keep-alive-requests=-1"); bind("server.tomcat.max-keep-alive-requests=-1");
customizeAndRunServer((server) -> assertThat( customizeAndRunServer((server) -> assertThat(
((AbstractHttp11Protocol<?>) server.getTomcat().getConnector().getProtocolHandler()) ((AbstractHttp11Protocol<?>) server.getTomcat().getConnector().getProtocolHandler())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment