aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-04-11 04:55:32 (EDT)
committerThomas Becker2012-04-11 04:55:32 (EDT)
commit5b7fe58593b3250b4f70ea6bc6c9d51a35c9b635 (patch)
tree50ff965687505d986a27fbf7e3871b3b7e4bf22b
parent241997b449f2f1781769adf2d76159e579c033d1 (diff)
downloadorg.eclipse.jetty.project-5b7fe58593b3250b4f70ea6bc6c9d51a35c9b635.zip
org.eclipse.jetty.project-5b7fe58593b3250b4f70ea6bc6c9d51a35c9b635.tar.gz
org.eclipse.jetty.project-5b7fe58593b3250b4f70ea6bc6c9d51a35c9b635.tar.bz2
376373: GzipFilter now does not ignore _excludePath + fix for ignored _excludeAgentPatterns if _excludeAgent is setrefs/changes/59/5559/1
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java12
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java70
2 files changed, 81 insertions, 1 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
index 1b993e6..4428ec1 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
@@ -238,7 +238,7 @@ public class GzipFilter extends UserAgentFilter
return true;
}
}
- else if (_excludedAgentPatterns != null)
+ if (_excludedAgentPatterns != null)
{
for (Pattern pattern : _excludedAgentPatterns)
{
@@ -263,6 +263,16 @@ public class GzipFilter extends UserAgentFilter
{
if (requestURI == null)
return false;
+ if (_excludedPaths != null)
+ {
+ for (String excludedPath : _excludedPaths)
+ {
+ if (requestURI.contains(excludedPath))
+ {
+ return true;
+ }
+ }
+ }
if (_excludedPathPatterns != null)
{
for (Pattern pattern : _excludedPathPatterns)
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
index 82fd54d..b9f7081 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
@@ -25,6 +25,8 @@ public class GzipFilterDefaultTest
public static class HttpStatusServlet extends HttpServlet
{
+ private static final long serialVersionUID = 1L;
+
private int _status = 204;
public HttpStatusServlet()
@@ -159,4 +161,72 @@ public class GzipFilterDefaultTest
tester.stop();
}
}
+
+ @Test
+ public void testUserAgentExclusionByExcludedAgentPatterns() throws Exception
+ {
+ GzipTester tester = new GzipTester(testingdir);
+
+ FilterHolder holder = tester.setContentServlet(DefaultServlet.class);
+ holder.setInitParameter("excludedAgents", "bar");
+ holder.setInitParameter("excludeAgentPatterns", "fo.*");
+ tester.setUserAgent("foo");
+
+ int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
+ tester.prepareServerFile("file.txt",filesize);
+
+ try
+ {
+ tester.start();
+ tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200);
+ }
+ finally
+ {
+ tester.stop();
+ }
+ }
+
+ @Test
+ public void testExcludePaths() throws Exception
+ {
+ GzipTester tester = new GzipTester(testingdir);
+
+ FilterHolder holder = tester.setContentServlet(DefaultServlet.class);
+ holder.setInitParameter("excludePaths", "/context/");
+
+ int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
+ tester.prepareServerFile("file.txt",filesize);
+
+ try
+ {
+ tester.start();
+ tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200);
+ }
+ finally
+ {
+ tester.stop();
+ }
+ }
+
+ @Test
+ public void testExcludePathPatterns() throws Exception
+ {
+ GzipTester tester = new GzipTester(testingdir);
+
+ FilterHolder holder = tester.setContentServlet(DefaultServlet.class);
+ holder.setInitParameter("excludePathPatterns", "/cont.*");
+
+ int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
+ tester.prepareServerFile("file.txt",filesize);
+
+ try
+ {
+ tester.start();
+ tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200);
+ }
+ finally
+ {
+ tester.stop();
+ }
+ }
}