Merge branch '3.1.x' into 3.2.x
Closes gh-40568
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import org.eclipse.jetty.http.UriCompliance;
|
||||
import org.eclipse.jetty.server.AllowedResourceAliasChecker;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||
@@ -30,24 +29,19 @@ import org.springframework.context.annotation.Configuration;
|
||||
/**
|
||||
* {@link JettyServerCustomizer} that:
|
||||
* <ul>
|
||||
* <li>Approves all aliases (Used for Windows CI on
|
||||
* Concourse)
|
||||
* <li>Relaxes URI compliance to allow access to static resources with {@code %} in their file name.
|
||||
* </ul>
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ConditionalOnClass(name = {"org.eclipse.jetty.server.handler.ContextHandler"})
|
||||
@ConditionalOnClass(name = "org.eclipse.jetty.server.Connector")
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class JettyServerCustomizerConfig {
|
||||
|
||||
@Bean
|
||||
public JettyServerCustomizer jettyServerCustomizer() {
|
||||
return (server) -> {
|
||||
ContextHandler handler = (ContextHandler) server.getHandler();
|
||||
handler.addAliasCheck((path, resource) -> true);
|
||||
|
||||
for (Connector connector : server.getConnectors()) {
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration()
|
||||
.setUriCompliance(UriCompliance.LEGACY);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,16 +16,12 @@
|
||||
|
||||
package smoketest.jetty.jsp;
|
||||
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@@ -36,8 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
classes = { SampleWebJspApplicationTests.JettyCustomizerConfig.class, SampleJettyJspApplication.class })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
class SampleWebJspApplicationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -50,19 +45,4 @@ class SampleWebJspApplicationTests {
|
||||
assertThat(entity.getBody()).contains("/resources/text.txt");
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class JettyCustomizerConfig {
|
||||
|
||||
// To allow aliased resources on Concourse Windows CI (See gh-15553) to be served
|
||||
// as static resources.
|
||||
@Bean
|
||||
JettyServerCustomizer jettyServerCustomizer() {
|
||||
return (server) -> {
|
||||
ContextHandler handler = (ContextHandler) server.getHandler();
|
||||
handler.addAliasCheck((path, resource) -> true);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user