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
This commit is contained in:
commit
842309e656
|
@ -613,6 +613,12 @@ public class Response implements HttpServletResponse
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name))
|
||||||
|
{
|
||||||
|
setContentType(value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_fields.add(name, value);
|
_fields.add(name, value);
|
||||||
if (HttpHeader.CONTENT_LENGTH.is(name))
|
if (HttpHeader.CONTENT_LENGTH.is(name))
|
||||||
{
|
{
|
||||||
|
|
|
@ -202,6 +202,10 @@ public class ResponseTest
|
||||||
response.setCharacterEncoding(null);
|
response.setCharacterEncoding(null);
|
||||||
response.setContentType("foo/bar");
|
response.setContentType("foo/bar");
|
||||||
assertEquals("foo/bar", response.getContentType());
|
assertEquals("foo/bar", response.getContentType());
|
||||||
|
response.recycle();
|
||||||
|
response.addHeader("Content-Type","text/something");
|
||||||
|
assertEquals("text/something",response.getContentType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -738,6 +738,8 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
||||||
{
|
{
|
||||||
r.reset(true);
|
r.reset(true);
|
||||||
r.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
r.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||||
|
if (_etags)
|
||||||
|
r.getHttpFields().add(HttpHeaders.ETAG_BUFFER,content.getETag());
|
||||||
r.flushBuffer();
|
r.flushBuffer();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -751,6 +753,8 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
||||||
{
|
{
|
||||||
r.reset(true);
|
r.reset(true);
|
||||||
r.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
r.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||||
|
if (_etags)
|
||||||
|
r.getHttpFields().add(HttpHeaders.ETAG_BUFFER,content.getETag());
|
||||||
r.flushBuffer();
|
r.flushBuffer();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class GzipFilterDefaultTest
|
||||||
String uri=req.getRequestURI();
|
String uri=req.getRequestURI();
|
||||||
if (uri.endsWith(".deferred"))
|
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)));
|
resp.setContentType(getServletContext().getMimeType(uri.substring(0,uri.length()-9)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,57 @@ public class GzipFilterDefaultTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testIsNotGzipCompressedWithQ() throws Exception
|
public void testIsNotGzipCompressedWithQ() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue