|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2021 the original author or authors.
|
|
|
|
* Copyright 2012-2022 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -28,6 +28,7 @@ import org.apache.catalina.valves.RemoteIpValve;
|
|
|
|
import org.apache.coyote.AbstractProtocol;
|
|
|
|
import org.apache.coyote.AbstractProtocol;
|
|
|
|
import org.apache.coyote.ajp.AbstractAjpProtocol;
|
|
|
|
import org.apache.coyote.ajp.AbstractAjpProtocol;
|
|
|
|
import org.apache.coyote.http11.AbstractHttp11Protocol;
|
|
|
|
import org.apache.coyote.http11.AbstractHttp11Protocol;
|
|
|
|
|
|
|
|
import org.apache.coyote.http2.Http2Protocol;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
|
@ -106,6 +107,22 @@ class TomcatWebServerFactoryCustomizerTests {
|
|
|
|
.isEqualTo(30));
|
|
|
|
.isEqualTo(30));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void defaultKeepAliveTimeoutWithHttp2() {
|
|
|
|
|
|
|
|
bind("server.http2.enabled=true");
|
|
|
|
|
|
|
|
customizeAndRunServer((server) -> assertThat(
|
|
|
|
|
|
|
|
((Http2Protocol) server.getTomcat().getConnector().findUpgradeProtocols()[0]).getKeepAliveTimeout())
|
|
|
|
|
|
|
|
.isEqualTo(20000L));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void customKeepAliveTimeoutWithHttp2() {
|
|
|
|
|
|
|
|
bind("server.tomcat.keep-alive-timeout=30s", "server.http2.enabled=true");
|
|
|
|
|
|
|
|
customizeAndRunServer((server) -> assertThat(
|
|
|
|
|
|
|
|
((Http2Protocol) server.getTomcat().getConnector().findUpgradeProtocols()[0]).getKeepAliveTimeout())
|
|
|
|
|
|
|
|
.isEqualTo(30000L));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void customMaxKeepAliveRequests() {
|
|
|
|
void customMaxKeepAliveRequests() {
|
|
|
|
bind("server.tomcat.max-keep-alive-requests=-1");
|
|
|
|
bind("server.tomcat.max-keep-alive-requests=-1");
|
|
|
@ -514,6 +531,7 @@ class TomcatWebServerFactoryCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
|
private TomcatServletWebServerFactory customizeAndGetFactory() {
|
|
|
|
private TomcatServletWebServerFactory customizeAndGetFactory() {
|
|
|
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
|
|
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
|
|
|
|
|
|
|
factory.setHttp2(this.serverProperties.getHttp2());
|
|
|
|
this.customizer.customize(factory);
|
|
|
|
this.customizer.customize(factory);
|
|
|
|
return factory;
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
}
|
|
|
|