|
|
|
@ -48,11 +48,11 @@ import org.eclipse.jetty.server.SessionManager;
|
|
|
|
|
import org.eclipse.jetty.server.SslConnectionFactory;
|
|
|
|
|
import org.eclipse.jetty.server.handler.ErrorHandler;
|
|
|
|
|
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|
|
|
|
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
|
|
|
|
import org.eclipse.jetty.server.session.HashSessionManager;
|
|
|
|
|
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
|
|
|
|
import org.eclipse.jetty.servlet.ServletHolder;
|
|
|
|
|
import org.eclipse.jetty.servlet.ServletMapping;
|
|
|
|
|
import org.eclipse.jetty.servlets.gzip.GzipHandler;
|
|
|
|
|
import org.eclipse.jetty.util.resource.JarResource;
|
|
|
|
|
import org.eclipse.jetty.util.resource.Resource;
|
|
|
|
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|
|
|
@ -752,50 +752,47 @@ public class JettyEmbeddedServletContainerFactory
|
|
|
|
|
|
|
|
|
|
private static class Jetty92GzipHandlerFactory implements GzipHandlerFactory {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HandlerWrapper createGzipHandler(Compression compression) {
|
|
|
|
|
GzipHandler gzipHandler = new GzipHandler();
|
|
|
|
|
gzipHandler.setMinGzipSize(compression.getMinResponseSize());
|
|
|
|
|
gzipHandler.addIncludedMimeTypes(compression.getMimeTypes());
|
|
|
|
|
if (compression.getExcludedUserAgents() != null) {
|
|
|
|
|
gzipHandler.setExcluded(new HashSet<String>(
|
|
|
|
|
Arrays.asList(compression.getExcludedUserAgents())));
|
|
|
|
|
}
|
|
|
|
|
return gzipHandler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HandlerWrapper createGzipHandler(Compression compression) {
|
|
|
|
|
try {
|
|
|
|
|
Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_3,
|
|
|
|
|
Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_2,
|
|
|
|
|
getClass().getClassLoader());
|
|
|
|
|
HandlerWrapper handler = (HandlerWrapper) handlerClass.newInstance();
|
|
|
|
|
HandlerWrapper gzipHandler = (HandlerWrapper) handlerClass.newInstance();
|
|
|
|
|
ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class)
|
|
|
|
|
.invoke(handler, compression.getMinResponseSize());
|
|
|
|
|
.invoke(gzipHandler, compression.getMinResponseSize());
|
|
|
|
|
ReflectionUtils
|
|
|
|
|
.findMethod(handlerClass, "setIncludedMimeTypes", String[].class)
|
|
|
|
|
.invoke(handler, new Object[] { compression.getMimeTypes() });
|
|
|
|
|
.findMethod(handlerClass, "addIncludedMimeTypes", String[].class)
|
|
|
|
|
.invoke(gzipHandler, new Object[] { compression.getMimeTypes() });
|
|
|
|
|
if (compression.getExcludedUserAgents() != null) {
|
|
|
|
|
ReflectionUtils
|
|
|
|
|
.findMethod(handlerClass, "setExcludedAgentPatterns",
|
|
|
|
|
String[].class)
|
|
|
|
|
.invoke(handler,
|
|
|
|
|
new Object[] { compression.getExcludedUserAgents() });
|
|
|
|
|
ReflectionUtils.findMethod(handlerClass, "setExcluded", Set.class)
|
|
|
|
|
.invoke(gzipHandler, new HashSet<String>(
|
|
|
|
|
Arrays.asList(compression.getExcludedUserAgents())));
|
|
|
|
|
}
|
|
|
|
|
return handler;
|
|
|
|
|
return gzipHandler;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
throw new RuntimeException("Failed to configure Jetty 9.3 gzip handler",
|
|
|
|
|
throw new RuntimeException("Failed to configure Jetty 9.2 gzip handler",
|
|
|
|
|
ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HandlerWrapper createGzipHandler(Compression compression) {
|
|
|
|
|
GzipHandler handler = new GzipHandler();
|
|
|
|
|
handler.setMinGzipSize(compression.getMinResponseSize());
|
|
|
|
|
handler.setIncludedMimeTypes(compression.getMimeTypes());
|
|
|
|
|
if (compression.getExcludedUserAgents() != null) {
|
|
|
|
|
handler.setExcludedAgentPatterns(compression.getExcludedUserAgents());
|
|
|
|
|
}
|
|
|
|
|
return handler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@link JettyServerCustomizer} to add {@link ForwardedRequestCustomizer}. Only
|
|
|
|
|
* supported with Jetty 9 (hence the inner class)
|
|
|
|
|