Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-05-31 04:06:34 -0400
committerGreg Wilkins2013-05-31 04:06:34 -0400
commit842309e656f8ca6e99a523ddbf98542fcab9ac47 (patch)
treebc35f205e6258a0bfcdca86f56f3122cd98c75b3 /jetty-servlets/src
parent8a09c4c7874415ebdc884dd4b0e3b3c8e5d8cbde (diff)
parent3849c893e17834c1bdb5fbf73ae911dd43ff1c6f (diff)
downloadorg.eclipse.jetty.project-842309e656f8ca6e99a523ddbf98542fcab9ac47.tar.gz
org.eclipse.jetty.project-842309e656f8ca6e99a523ddbf98542fcab9ac47.tar.xz
org.eclipse.jetty.project-842309e656f8ca6e99a523ddbf98542fcab9ac47.zip
Merge remote-tracking branch 'origin/jetty-8'
Conflicts: jetty-server/src/main/java/org/eclipse/jetty/server/Response.java jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
Diffstat (limited to 'jetty-servlets/src')
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java53
1 files changed, 52 insertions, 1 deletions
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 d2c9eafd37..c496f0563d 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
@@ -145,7 +145,7 @@ public class GzipFilterDefaultTest
String uri=req.getRequestURI();
if (uri.endsWith(".deferred"))
{
- System.err.println("type for "+uri.substring(0,uri.length()-9)+" is "+getServletContext().getMimeType(uri.substring(0,uri.length()-9)));
+ // System.err.println("type for "+uri.substring(0,uri.length()-9)+" is "+getServletContext().getMimeType(uri.substring(0,uri.length()-9)));
resp.setContentType(getServletContext().getMimeType(uri.substring(0,uri.length()-9)));
}
@@ -272,6 +272,57 @@ public class GzipFilterDefaultTest
tester.stop();
}
}
+
+
+ @Test
+ public void testGzipedIfModified() throws Exception
+ {
+ GzipTester tester = new GzipTester(testingdir, compressionType);
+
+ // Test content that is smaller than the buffer.
+ int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
+ tester.prepareServerFile("file.txt",filesize);
+
+ FilterHolder holder = tester.setContentServlet(org.eclipse.jetty.servlet.DefaultServlet.class);
+ holder.setInitParameter("mimeTypes","text/plain");
+
+ try
+ {
+ tester.start();
+ HttpTester http = tester.assertIsResponseGzipCompressed("GET","file.txt",System.currentTimeMillis()-4000);
+ Assert.assertEquals("Accept-Encoding",http.getHeader("Vary"));
+ }
+ finally
+ {
+ tester.stop();
+ }
+ }
+
+
+ @Test
+ public void testNotGzipedIfNotModified() throws Exception
+ {
+ GzipTester tester = new GzipTester(testingdir, compressionType);
+
+ // Test content that is smaller than the buffer.
+ int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
+ tester.prepareServerFile("file.txt",filesize);
+
+ FilterHolder holder = tester.setContentServlet(org.eclipse.jetty.servlet.DefaultServlet.class);
+ holder.setInitParameter("mimeTypes","text/plain");
+ holder.setInitParameter("etags","true");
+
+ try
+ {
+ tester.start();
+ HttpTester http = tester.assertIsResponseNotModified("GET","file.txt",System.currentTimeMillis()+4000);
+ }
+ finally
+ {
+ tester.stop();
+ }
+ }
+
@Test
public void testIsNotGzipCompressedWithQ() throws Exception

Back to the top