Merge branch 'jetty-9.4.x' into jetty-9.4.x-3989-selector-failure
This commit is contained in:
commit
7f1396a766
|
@ -78,6 +78,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.OS;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@Disabled("See issue #3974")
|
||||||
public class AsyncMiddleManServletTest
|
public class AsyncMiddleManServletTest
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(AsyncMiddleManServletTest.class);
|
private static final Logger LOG = Log.getLogger(AsyncMiddleManServletTest.class);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.CompressedContentFormat;
|
import org.eclipse.jetty.http.CompressedContentFormat;
|
||||||
import org.eclipse.jetty.http.HttpField;
|
import org.eclipse.jetty.http.HttpField;
|
||||||
|
import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
@ -442,7 +443,8 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
|
||||||
@Override
|
@Override
|
||||||
public Deflater getDeflater(Request request, long contentLength)
|
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))
|
if (ua != null && !isAgentGzipable(ua))
|
||||||
{
|
{
|
||||||
LOG.debug("{} excluded user agent {}", this, request);
|
LOG.debug("{} excluded user agent {}", this, request);
|
||||||
|
@ -456,16 +458,7 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the accept encoding header
|
// check the accept encoding header
|
||||||
HttpField accept = request.getHttpFields().getField(HttpHeader.ACCEPT_ENCODING);
|
if (!httpFields.contains(HttpHeader.ACCEPT_ENCODING, "gzip"))
|
||||||
|
|
||||||
if (accept == null)
|
|
||||||
{
|
|
||||||
LOG.debug("{} excluded !accept {}", this, request);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
boolean gzip = accept.contains("gzip");
|
|
||||||
|
|
||||||
if (!gzip)
|
|
||||||
{
|
{
|
||||||
LOG.debug("{} excluded not gzip accept {}", this, request);
|
LOG.debug("{} excluded not gzip accept {}", this, request);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -161,11 +161,6 @@ public class SessionData implements Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs)
|
public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs)
|
||||||
{
|
|
||||||
this(id, cpath, vhost, created, accessed, lastAccessed, maxInactiveMs, new ConcurrentHashMap<String, Object>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs, Map<String, Object> attributes)
|
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
setContextPath(cpath);
|
setContextPath(cpath);
|
||||||
|
@ -175,7 +170,13 @@ public class SessionData implements Serializable
|
||||||
_lastAccessed = lastAccessed;
|
_lastAccessed = lastAccessed;
|
||||||
_maxInactiveMs = maxInactiveMs;
|
_maxInactiveMs = maxInactiveMs;
|
||||||
calcAndSetExpiry();
|
calcAndSetExpiry();
|
||||||
_attributes = attributes;
|
_attributes = new ConcurrentHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SessionData(String id, String cpath, String vhost, long created, long accessed, long lastAccessed, long maxInactiveMs, Map<String, Object> attributes)
|
||||||
|
{
|
||||||
|
this(id, cpath, vhost, created, accessed, lastAccessed, maxInactiveMs);
|
||||||
|
putAllAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -285,6 +285,34 @@ public class GzipHandlerTest
|
||||||
assertEquals(__content, testOut.toString("UTF8"));
|
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
|
@Test
|
||||||
public void testGzipNotMicro() throws Exception
|
public void testGzipNotMicro() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue