Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
103a5065c9
|
@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.http.CompressedContentFormat;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
|
@ -422,7 +423,8 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
|
|||
@Override
|
||||
public Deflater getDeflater(Request request, long contentLength)
|
||||
{
|
||||
String ua = request.getHttpFields().get(HttpHeader.USER_AGENT);
|
||||
HttpFields httpFields = request.getHttpFields();
|
||||
String ua = httpFields.get(HttpHeader.USER_AGENT);
|
||||
if (ua != null && !isAgentGzipable(ua))
|
||||
{
|
||||
LOG.debug("{} excluded user agent {}", this, request);
|
||||
|
@ -436,16 +438,7 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
|
|||
}
|
||||
|
||||
// check the accept encoding header
|
||||
HttpField accept = request.getHttpFields().getField(HttpHeader.ACCEPT_ENCODING);
|
||||
|
||||
if (accept == null)
|
||||
{
|
||||
LOG.debug("{} excluded !accept {}", this, request);
|
||||
return null;
|
||||
}
|
||||
boolean gzip = accept.contains("gzip");
|
||||
|
||||
if (!gzip)
|
||||
if (!httpFields.contains(HttpHeader.ACCEPT_ENCODING, "gzip"))
|
||||
{
|
||||
LOG.debug("{} excluded not gzip accept {}", this, request);
|
||||
return null;
|
||||
|
|
|
@ -285,6 +285,34 @@ public class GzipHandlerTest
|
|||
assertEquals(__content, testOut.toString("UTF8"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGzipHandlerWithMultipleAcceptEncodingHeaders() throws Exception
|
||||
{
|
||||
// generated and parsed test
|
||||
HttpTester.Request request = HttpTester.newRequest();
|
||||
HttpTester.Response response;
|
||||
|
||||
request.setMethod("GET");
|
||||
request.setURI("/ctx/content?vary=Accept-Encoding,Other");
|
||||
request.setVersion("HTTP/1.0");
|
||||
request.setHeader("Host", "tester");
|
||||
request.setHeader("accept-encoding", "deflate");
|
||||
request.setHeader("accept-encoding", "gzip");
|
||||
|
||||
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
|
||||
|
||||
assertThat(response.getStatus(), is(200));
|
||||
assertThat(response.get("Content-Encoding"), Matchers.equalToIgnoringCase("gzip"));
|
||||
assertThat(response.get("ETag"), is(__contentETagGzip));
|
||||
assertThat(response.getCSV("Vary", false), Matchers.contains("Accept-Encoding", "Other"));
|
||||
|
||||
InputStream testIn = new GZIPInputStream(new ByteArrayInputStream(response.getContentBytes()));
|
||||
ByteArrayOutputStream testOut = new ByteArrayOutputStream();
|
||||
IO.copy(testIn, testOut);
|
||||
|
||||
assertEquals(__content, testOut.toString("UTF8"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGzipNotMicro() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue