Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2013-06-30 23:37:08 +0000
committerJoakim Erdfelt2013-06-30 23:37:08 +0000
commitaa1aae182af1034edd4e895a5e1fcb8e2f47abb1 (patch)
treedec68f8198c6fb7273eb487af251ff3a06be4241
parentf262dce23b21a9af3e67254181bed29cb2909d6e (diff)
downloadorg.eclipse.jetty.project-aa1aae182af1034edd4e895a5e1fcb8e2f47abb1.tar.gz
org.eclipse.jetty.project-aa1aae182af1034edd4e895a5e1fcb8e2f47abb1.tar.xz
org.eclipse.jetty.project-aa1aae182af1034edd4e895a5e1fcb8e2f47abb1.zip
Instituting Content-Length OR Transfer-Encoding check in GzipFilter tests
+ Tests currently fail, will let greg look deeply into jetty's eyes to determine why it defiantly doesn't want to cooperate with greg.
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java23
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWriteWithFlush.java3
2 files changed, 13 insertions, 13 deletions
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
index c5a104a685..ad3ea63a5e 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
@@ -18,13 +18,8 @@
package org.eclipse.jetty.servlets.gzip;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -56,7 +51,6 @@ import org.eclipse.jetty.testing.ServletTester;
import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
-import org.eclipse.jetty.util.DateCache;
import org.hamcrest.Matchers;
import org.junit.Assert;
@@ -116,10 +110,15 @@ public class GzipTester
// Assert the response headers
Assert.assertThat("Response.method",response.getMethod(),nullValue());
- // Assert.assertThat("Response.status",response.getStatus(),is(HttpServletResponse.SC_OK));
- if ( response.getHeader("X-Testing-Skip-Content-Length") == null )
- {
- Assert.assertThat("Response.header[Content-Length]",response.getHeader("Content-Length"),notNullValue());
+
+ // Response headers should have either a Transfer-Encoding indicating chunked OR a Content-Length
+ String contentLength = response.getHeader("Content-Length");
+ String transferEncoding = response.getHeader("Transfer-Encoding");
+ boolean chunked = (transferEncoding != null) && (transferEncoding.indexOf("chunk") >= 0);
+ if(!chunked) {
+ Assert.assertThat("Response.header[Content-Length]",contentLength,notNullValue());
+ } else {
+ Assert.assertThat("Response.header[Transfer-Encoding]",transferEncoding,notNullValue());
}
int qindex = compressionType.indexOf(";");
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWriteWithFlush.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWriteWithFlush.java
index d1cd1b1067..ff8841c163 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWriteWithFlush.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWriteWithFlush.java
@@ -53,8 +53,8 @@ public class TestServletStreamLengthTypeWriteWithFlush extends TestDirContentSer
ServletOutputStream out = response.getOutputStream();
+ // set content-length of uncompressed content (GzipFilter should handle this)
response.setContentLength(dataBytes.length);
- response.setHeader("X-Testing-Skip-Content-Length","true");
if (fileName.endsWith("txt"))
response.setContentType("text/plain");
@@ -65,6 +65,7 @@ public class TestServletStreamLengthTypeWriteWithFlush extends TestDirContentSer
for ( int i = 0 ; i < dataBytes.length ; i++)
{
out.write(dataBytes[i]);
+ // flush using response object (not the stream itself)
response.flushBuffer();
}
}

Back to the top