Issue #1761 - add extra .ini file configuration for gzip.mod

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-09-08 09:46:51 +10:00
parent 7642be8fd0
commit 17ec87f51c
3 changed files with 40 additions and 3 deletions

View File

@ -18,8 +18,13 @@
<Set name="inflateBufferSize" property="jetty.gzip.inflateBufferSize"/>
<Set name="deflaterPoolCapacity" property="jetty.gzip.deflaterPoolCapacity"/>
<Set name="syncFlush" property="jetty.gzip.syncFlush"/>
<Set name="dispatcherTypes" property="jetty.gzip.dispatcherTypes"/>
<Set name="includedMethodList" property="jetty.gzip.includedMethodList"/>
<Set name="excludedMethodList" property="jetty.gzip.excludedMethodList"/>
<Set name="includedMimeTypes" property="jetty.gzip.includedMimeTypeList"/>
<Set name="excludedMimeTypes" property="jetty.gzip.excludedMimeTypeList"/>
<Set name="includedPaths" property="jetty.gzip.includedPathList"/>
<Set name="excludedPaths" property="jetty.gzip.excludedPathList"/>
<!--
<Set name="includedMethods">

View File

@ -29,8 +29,26 @@ etc/jetty-gzip.xml
## Deflater pool max size (-1 for unlimited, 0 for no pool)
# jetty.gzip.deflaterPoolCapacity=-1
## Comma separated list of included methods
## Set the {@link Deflater} flush mode to use.
# jetty.gzip.syncFlush=false
## The set of DispatcherType that this filter will operate on
# jetty.gzip.dispatcherTypes=REQUEST
## Comma separated list of included HTTP methods
# jetty.gzip.includedMethodList=GET,POST
## Comma separated list of excluded methods
## Comma separated list of excluded HTTP methods
# jetty.gzip.excludedMethodList=
## Comma separated list of included MIME types
# jetty.gzip.includedMimeTypeList=
## Comma separated list of excluded MIME types
# jetty.gzip.excludedMimeTypeList=
## Comma separated list of included Path specs
# jetty.gzip.includedPathList=
## Comma separated list of excluded Path specs
# jetty.gzip.excludedPathList=

View File

@ -24,6 +24,7 @@ import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.zip.Deflater;
import javax.servlet.DispatcherType;
import javax.servlet.ServletContext;
@ -772,6 +773,19 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
_paths.exclude(pathspecs);
}
/**
* Set of supported {@link DispatcherType} that this filter will operate on.
*
* @param dispatchers the set of {@link DispatcherType} that this filter will operate on
*/
public void setDispatcherTypes(String... dispatchers)
{
setDispatcherTypes(Stream.of(dispatchers)
.flatMap(s -> Stream.of(StringUtil.csvSplit(s)))
.map(DispatcherType::valueOf)
.toArray(DispatcherType[]::new));
}
/**
* Set the included filter list of HTTP methods (replacing any previously set)
*
@ -902,7 +916,7 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
return String.format("%s@%x{%s,min=%s,inflate=%s}", getClass().getSimpleName(), hashCode(), getState(), _minGzipSize, _inflateBufferSize);
}
private static class CaseInsensitiveSet extends HashSet<String>
public static class CaseInsensitiveSet extends HashSet<String>
{
@Override
public boolean add(String s)