Polish "Default use-relative-redirects to true"

See gh-51173

Signed-off-by: Andy Wilkinson <andy.wilkinson@broadcom.com>
This commit is contained in:
Andy Wilkinson
2026-09-07 08:55:46 +01:00
parent f119e58767
commit 8924f1691c
3 changed files with 8 additions and 5 deletions
@@ -56,7 +56,6 @@ import org.springframework.util.unit.DataSize;
* @author Florian Storz
* @author Michael Weidmann
* @author Lasse Wulff
* @author Tiziano Basile
* @since 4.0.0
*/
@ConfigurationProperties("server.tomcat")
@@ -104,7 +103,7 @@ public class TomcatServerProperties {
/**
* Whether HTTP 1.1 and later location headers generated by a call to sendRedirect
* will use relative or absolute redirects. Has no effect on a reactive web server.
* will use relative or absolute redirects.
*/
private boolean useRelativeRedirects = true;
@@ -29,7 +29,6 @@ import org.springframework.util.ObjectUtils;
*
* @author Brian Clozel
* @author Phillip Webb
* @author Tiziano Basile
*/
class TomcatServletWebServerFactoryCustomizer
implements WebServerFactoryCustomizer<TomcatServletWebServerFactory>, Ordered {
@@ -74,7 +74,7 @@ class TomcatServerPropertiesTests {
map.put("server.tomcat.background-processor-delay", "10");
map.put("server.tomcat.relaxed-path-chars", "|,<");
map.put("server.tomcat.relaxed-query-chars", "^ , | ");
map.put("server.tomcat.use-relative-redirects", "true");
map.put("server.tomcat.use-relative-redirects", "false");
bind(map);
Accesslog accesslog = this.properties.getAccesslog();
assertThat(accesslog.getConditionIf()).isEqualTo("foo");
@@ -96,7 +96,7 @@ class TomcatServerPropertiesTests {
assertThat(this.properties.getBackgroundProcessorDelay()).hasSeconds(10);
assertThat(this.properties.getRelaxedPathChars()).containsExactly('|', '<');
assertThat(this.properties.getRelaxedQueryChars()).containsExactly('^', '|');
assertThat(this.properties.isUseRelativeRedirects()).isTrue();
assertThat(this.properties.isUseRelativeRedirects()).isFalse();
}
@Test
@@ -240,6 +240,11 @@ class TomcatServerPropertiesTests {
assertThat(this.properties.isUseRelativeRedirects()).isTrue();
}
@Test
void tomcatUseRelativeRedirectsMatchesDefault() {
assertThat(this.properties.isUseRelativeRedirects()).isEqualTo(new StandardContext().getUseRelativeRedirects());
}
@Test
void tomcatMaxKeepAliveRequestsDefault() throws Exception {
AbstractEndpoint<?, ?> endpoint = (AbstractEndpoint<?, ?>) ReflectionTestUtils.getField(getDefaultProtocol(),