From 08573701efc447fb95da22bfc711f79b6908a60e Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 11 Apr 2012 14:47:28 +0200 Subject: [PATCH] 376373: GzipFilter now does not ignore _excludePath + fix for ignored _excludeAgentPatterns if _excludeAgent is set Change-Id: Ie9940141f9b92b267f4b405ef4ec3ab5dee43be5 --- .../eclipse/jetty/servlets/GzipFilter.java | 6 +- .../jetty/servlets/GzipFilterDefaultTest.java | 79 +++++++++---------- 2 files changed, 42 insertions(+), 43 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 94d50dee76d..650632b7f38 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 @@ -303,7 +303,7 @@ public class GzipFilter extends UserAgentFilter } /** - * Checks to see if the UserAgent is excluded + * Checks to see if the userAgent is excluded * * @param ua * the user agent @@ -336,9 +336,9 @@ public class GzipFilter extends UserAgentFilter } /** - * Checks to see if the Path is excluded + * Checks to see if the path is excluded * - * @param ua + * @param requestURI * the request uri * @return boolean true if excluded */ 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 89f2f458534..05f53c97e3e 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 @@ -31,11 +31,10 @@ public class GzipFilterDefaultTest public static Collection data() { String[][] data = new String[][] - { - { GzipFilter.GZIP }, - { GzipFilter.DEFLATE } - }; - + { + { GzipFilter.GZIP }, + { GzipFilter.DEFLATE } }; + return Arrays.asList(data); } @@ -166,88 +165,88 @@ public class GzipFilterDefaultTest @Test public void testUserAgentExclusion() throws Exception { - GzipTester tester = new GzipTester(testingdir, compressionType); - + GzipTester tester = new GzipTester(testingdir,compressionType); + FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludedAgents", "foo"); + holder.setInitParameter("excludedAgents","foo"); tester.setUserAgent("foo"); - + int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; tester.prepareServerFile("file.txt",filesize); - + try { tester.start(); - tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200); - } + tester.assertIsResponseNotGzipCompressed("file.txt",filesize,HttpStatus.OK_200); + } finally { tester.stop(); } } - + @Test public void testUserAgentExclusionByExcludedAgentPatterns() throws Exception { - GzipTester tester = new GzipTester(testingdir); - + GzipTester tester = new GzipTester(testingdir,compressionType); + FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludedAgents", "bar"); - holder.setInitParameter("excludeAgentPatterns", "fo.*"); + holder.setInitParameter("excludedAgents","bar"); + holder.setInitParameter("excludeAgentPatterns","fo.*"); tester.setUserAgent("foo"); - - int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4; + + int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; tester.prepareServerFile("file.txt",filesize); - + try { tester.start(); - tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200); - } + tester.assertIsResponseNotGzipCompressed("file.txt",filesize,HttpStatus.OK_200); + } finally { tester.stop(); } } - + @Test public void testExcludePaths() throws Exception { - GzipTester tester = new GzipTester(testingdir); - + GzipTester tester = new GzipTester(testingdir,compressionType); + FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludePaths", "/context/"); - - int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4; + holder.setInitParameter("excludePaths","/context/"); + + int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; tester.prepareServerFile("file.txt",filesize); - + try { tester.start(); - tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200); - } + tester.assertIsResponseNotGzipCompressed("file.txt",filesize,HttpStatus.OK_200); + } finally { tester.stop(); } } - + @Test public void testExcludePathPatterns() throws Exception { - GzipTester tester = new GzipTester(testingdir); - + GzipTester tester = new GzipTester(testingdir,compressionType); + FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludePathPatterns", "/cont.*"); - - int filesize = GzipResponseWrapper.DEFAULT_BUFFER_SIZE * 4; + holder.setInitParameter("excludePathPatterns","/cont.*"); + + int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; tester.prepareServerFile("file.txt",filesize); - + try { tester.start(); - tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200); - } + tester.assertIsResponseNotGzipCompressed("file.txt",filesize,HttpStatus.OK_200); + } finally { tester.stop();