Skip to content

Commit

Permalink
Issue #1761 - add extra .ini file configuration for gzip.mod
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Sep 7, 2020
1 parent 7642be8 commit 17ec87f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
5 changes: 5 additions & 0 deletions jetty-server/src/main/config/etc/jetty-gzip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
22 changes: 20 additions & 2 deletions jetty-server/src/main/config/modules/gzip.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -772,6 +773,19 @@ public void setExcludedPaths(String... pathspecs)
_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)
*
Expand Down Expand Up @@ -902,7 +916,7 @@ public String toString()
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)
Expand Down

0 comments on commit 17ec87f

Please sign in to comment.