commit
e5497665cf
|
|
@ -203,7 +203,7 @@
|
|||
<thymeleaf-extras-java8time.version>3.0.4.RELEASE</thymeleaf-extras-java8time.version>
|
||||
<tomcat.version>9.0.21</tomcat.version>
|
||||
<unboundid-ldapsdk.version>4.0.11</unboundid-ldapsdk.version>
|
||||
<undertow.version>2.0.21.Final</undertow.version>
|
||||
<undertow.version>2.0.22.Final</undertow.version>
|
||||
<webjars-hal-browser.version>3325375</webjars-hal-browser.version>
|
||||
<webjars-locator-core.version>0.37</webjars-locator-core.version>
|
||||
<woodstox.version>5.0.3</woodstox.version>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -57,6 +60,7 @@ import io.undertow.servlet.api.ListenerInfo;
|
|||
import io.undertow.servlet.api.MimeMapping;
|
||||
import io.undertow.servlet.api.ServletContainerInitializerInfo;
|
||||
import io.undertow.servlet.api.ServletStackTraces;
|
||||
import io.undertow.servlet.core.DeploymentImpl;
|
||||
import io.undertow.servlet.handlers.DefaultServlet;
|
||||
import io.undertow.servlet.util.ImmediateInstanceFactory;
|
||||
import org.xnio.OptionMap;
|
||||
|
|
@ -282,6 +286,9 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
|
|||
addLocaleMappings(deployment);
|
||||
DeploymentManager manager = Servlets.newContainer().addDeployment(deployment);
|
||||
manager.deploy();
|
||||
if (manager.getDeployment() instanceof DeploymentImpl) {
|
||||
removeSuperfluousMimeMappings((DeploymentImpl) manager.getDeployment(), deployment);
|
||||
}
|
||||
SessionManager sessionManager = manager.getDeployment().getSessionManager();
|
||||
Duration timeoutDuration = getSession().getTimeout();
|
||||
int sessionTimeout = (isZeroOrLess(timeoutDuration) ? -1 : (int) timeoutDuration.getSeconds());
|
||||
|
|
@ -416,6 +423,16 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
|
|||
}
|
||||
}
|
||||
|
||||
private void removeSuperfluousMimeMappings(DeploymentImpl deployment, DeploymentInfo deploymentInfo) {
|
||||
// DeploymentManagerImpl will always add MimeMappings.DEFAULT_MIME_MAPPINGS
|
||||
// but we only want ours
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
for (MimeMapping mapping : deploymentInfo.getMimeMappings()) {
|
||||
mappings.put(mapping.getExtension().toLowerCase(Locale.ENGLISH), mapping.getMimeType());
|
||||
}
|
||||
deployment.setMimeExtensionMappings(mappings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method called to create the {@link UndertowServletWebServer}. Subclasses
|
||||
* can override this method to return a different {@link UndertowServletWebServer} or
|
||||
|
|
|
|||
|
|
@ -22,11 +22,8 @@ import java.net.SocketException;
|
|||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
|
|
@ -42,7 +39,6 @@ import org.mockito.InOrder;
|
|||
|
||||
import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
|
||||
import org.springframework.boot.web.server.ErrorPage;
|
||||
import org.springframework.boot.web.server.MimeMappings.Mapping;
|
||||
import org.springframework.boot.web.server.PortInUseException;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
||||
|
|
@ -261,15 +257,6 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
|
|||
.getMimeExtensionMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Mapping> getExpectedMimeMappings() {
|
||||
// Unlike Tomcat and Jetty, Undertow performs a case-sensitive match on file
|
||||
// extension so it has a mapping for "z" and "Z".
|
||||
Set<Mapping> expectedMappings = new HashSet<>(super.getExpectedMimeMappings());
|
||||
expectedMappings.add(new Mapping("Z", "application/x-compress"));
|
||||
return expectedMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Charset getCharset(Locale locale) {
|
||||
DeploymentInfo info = ((UndertowServletWebServer) this.webServer).getDeploymentManager().getDeployment()
|
||||
|
|
|
|||
|
|
@ -779,7 +779,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|||
AbstractServletWebServerFactory factory = getFactory();
|
||||
this.webServer = factory.getWebServer();
|
||||
Map<String, String> configuredMimeMappings = getActualMimeMappings();
|
||||
Collection<MimeMappings.Mapping> expectedMimeMappings = getExpectedMimeMappings();
|
||||
Collection<MimeMappings.Mapping> expectedMimeMappings = MimeMappings.DEFAULT.getAll();
|
||||
configuredMimeMappings.forEach(
|
||||
(key, value) -> assertThat(expectedMimeMappings).contains(new MimeMappings.Mapping(key, value)));
|
||||
for (MimeMappings.Mapping mapping : expectedMimeMappings) {
|
||||
|
|
@ -1016,10 +1016,6 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|||
|
||||
protected abstract Map<String, String> getActualMimeMappings();
|
||||
|
||||
protected Collection<MimeMappings.Mapping> getExpectedMimeMappings() {
|
||||
return MimeMappings.DEFAULT.getAll();
|
||||
}
|
||||
|
||||
protected abstract Charset getCharset(Locale locale);
|
||||
|
||||
private void addTestTxtFile(AbstractServletWebServerFactory factory) throws IOException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue