Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
commit
d2df269752
|
@ -104,13 +104,11 @@ public class HttpStreamOverHTTP3 implements HttpStream
|
|||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onRequest() failure", x);
|
||||
onBadMessage(x);
|
||||
return null;
|
||||
return () -> onBadMessage(x);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
onBadMessage(new BadMessageException(HttpStatus.INTERNAL_SERVER_ERROR_500, null, x));
|
||||
return null;
|
||||
return () -> onBadMessage(new BadMessageException(HttpStatus.INTERNAL_SERVER_ERROR_500, null, x));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -538,6 +538,8 @@ public class GzipHandler extends Handler.Wrapper implements GzipFactory
|
|||
GzipRequest gzipRequest = Request.as(request, GzipRequest.class);
|
||||
boolean alreadyGzipped = gzipRequest != null;
|
||||
|
||||
// TODO: skip wrapping the response if it is already committed.
|
||||
|
||||
// TODO: Move down. can we return super.handle(request) without these changes?
|
||||
// Update headers for etags and inflation
|
||||
HttpFields.Mutable newFields = null;
|
||||
|
@ -920,4 +922,4 @@ public class GzipHandler extends Handler.Wrapper implements GzipFactory
|
|||
{
|
||||
return String.format("%s@%x{%s,min=%s,inflate=%s}", getClass().getSimpleName(), hashCode(), getState(), _minGzipSize, _inflateBufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.ee9.servlet;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
* Tests of behavior of GzipHandler when Request.isHandled() or Response.isCommitted() is true
|
||||
*/
|
||||
// TODO: re-enable when the PathResource work has been integrated.
|
||||
@Disabled()
|
||||
public class GzipHandlerIsHandledTest
|
||||
{
|
||||
public WorkDir workDir;
|
||||
|
||||
private Server server;
|
||||
private HttpClient client;
|
||||
public LinkedBlockingQueue<String> events = new LinkedBlockingQueue<>();
|
||||
|
||||
public void startServer(Handler rootHandler) throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
server.addConnector(connector);
|
||||
|
||||
server.setHandler(rootHandler);
|
||||
server.start();
|
||||
|
||||
client = new HttpClient();
|
||||
client.start();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown()
|
||||
{
|
||||
LifeCycle.stop(client);
|
||||
LifeCycle.stop(server);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequest() throws Exception
|
||||
{
|
||||
Handler.Collection handlers = new Handler.Collection();
|
||||
|
||||
ResourceHandler resourceHandler = new ResourceHandler();
|
||||
resourceHandler.setBaseResource(workDir.getPath());
|
||||
// TODO: fix when the PathResource work has been integrated.
|
||||
// resourceHandler.setDirectoriesListed(true);
|
||||
resourceHandler.setHandler(new EventHandler(events, "ResourceHandler"));
|
||||
|
||||
GzipHandler gzipHandler = new GzipHandler();
|
||||
gzipHandler.setMinGzipSize(32);
|
||||
gzipHandler.setHandler(new EventHandler(events, "GzipHandler-wrapped-handler"));
|
||||
|
||||
handlers.setHandlers(resourceHandler, gzipHandler, new DefaultHandler());
|
||||
|
||||
startServer(handlers);
|
||||
|
||||
ContentResponse response = client.GET(server.getURI().resolve("/"));
|
||||
assertThat("response.status", response.getStatus(), is(200));
|
||||
// we should have received a directory listing from the ResourceHandler
|
||||
assertThat("response.content", response.getContentAsString(), containsString("Directory: /"));
|
||||
// resource handler should have handled the request
|
||||
// the gzip handler and default handlers should have been executed, seeing as this is a HandlerCollection
|
||||
// but the gzip handler should not have acted on the request, as the response is committed
|
||||
assertThat("One event should have been recorded", events.size(), is(1));
|
||||
// the event handler should see the request.isHandled = true
|
||||
// and response.isCommitted = true as the gzip handler didn't really do anything due to these
|
||||
// states and let the wrapped handler (the EventHandler in this case) make the call on what it should do.
|
||||
assertThat("Event indicating that GzipHandler-wrapped-handler ran", events.remove(), is("GzipHandler-wrapped-handler"));
|
||||
}
|
||||
|
||||
private static class EventHandler extends Handler.Abstract
|
||||
{
|
||||
private final LinkedBlockingQueue<String> events;
|
||||
private final String action;
|
||||
|
||||
public EventHandler(LinkedBlockingQueue<String> events, String action)
|
||||
{
|
||||
this.events = events;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request.Processor handle(Request request)
|
||||
{
|
||||
events.offer(action);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@
|
|||
artifacts are created -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-bom</artifactId>
|
||||
<artifactId>jetty-home</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
|
16
pom.xml
16
pom.xml
|
@ -48,7 +48,7 @@
|
|||
<hazelcast.version>4.2.5</hazelcast.version>
|
||||
<infinispan.protostream.version>4.4.3.Final</infinispan.protostream.version>
|
||||
<infinispan.version>11.0.15.Final</infinispan.version>
|
||||
<jackson.databind.version>2.13.2.2</jackson.databind.version>
|
||||
<jackson.databind.version>2.13.3</jackson.databind.version>
|
||||
<jboss.logging.annotations.version>2.2.1.Final</jboss.logging.annotations.version>
|
||||
<jboss.logging.processor.version>2.2.1.Final</jboss.logging.processor.version>
|
||||
<jboss.logging.version>3.5.0.Final</jboss.logging.version>
|
||||
|
@ -72,7 +72,7 @@
|
|||
<junit.version>5.8.2</junit.version>
|
||||
<kerb-simplekdc.version>2.0.2</kerb-simplekdc.version>
|
||||
<log4j2.version>2.17.2</log4j2.version>
|
||||
<logback.version>1.3.0-alpha15</logback.version>
|
||||
<logback.version>1.3.0-alpha16</logback.version>
|
||||
<mariadb.version>3.0.4</mariadb.version>
|
||||
<mariadb.docker.version>10.3.6</mariadb.docker.version>
|
||||
<maven.deps.version>3.8.4</maven.deps.version>
|
||||
|
@ -86,12 +86,12 @@
|
|||
<org.osgi.util.function.version>1.2.0</org.osgi.util.function.version>
|
||||
<org.osgi.util.promise.version>1.2.0</org.osgi.util.promise.version>
|
||||
<plexus-component-annotations.version>2.1.1</plexus-component-annotations.version>
|
||||
<plexus-utils.version>3.4.1</plexus-utils.version>
|
||||
<plexus-utils.version>3.4.2</plexus-utils.version>
|
||||
<slf4j.version>2.0.0-alpha6</slf4j.version>
|
||||
<springboot.version>2.1.1.RELEASE</springboot.version>
|
||||
<taglibs-standard-impl.version>1.2.5</taglibs-standard-impl.version>
|
||||
<taglibs-standard-spec.version>1.2.5</taglibs-standard-spec.version>
|
||||
<testcontainers.version>1.16.2</testcontainers.version>
|
||||
<testcontainers.version>1.17.2</testcontainers.version>
|
||||
<xmemcached.version>2.4.7</xmemcached.version>
|
||||
<weld.version>4.0.2.Final</weld.version>
|
||||
|
||||
|
@ -109,8 +109,8 @@
|
|||
<license.maven.plugin.version>4.1</license.maven.plugin.version>
|
||||
<maven.antrun.plugin.version>3.0.0</maven.antrun.plugin.version>
|
||||
<maven.assembly.plugin.version>3.3.0</maven.assembly.plugin.version>
|
||||
<maven.bundle.plugin.version>5.1.4</maven.bundle.plugin.version>
|
||||
<maven.clean.plugin.version>3.1.0</maven.clean.plugin.version>
|
||||
<maven.bundle.plugin.version>5.1.6</maven.bundle.plugin.version>
|
||||
<maven.clean.plugin.version>3.2.0</maven.clean.plugin.version>
|
||||
<maven.checkstyle.plugin.version>3.1.2</maven.checkstyle.plugin.version>
|
||||
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
|
||||
<maven.dependency.plugin.version>3.2.0</maven.dependency.plugin.version>
|
||||
|
@ -135,8 +135,8 @@
|
|||
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
|
||||
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
|
||||
<maven.war.plugin.version>3.3.2</maven.war.plugin.version>
|
||||
<spotbugs.maven.plugin.version>4.5.3.0</spotbugs.maven.plugin.version>
|
||||
<versions.maven.plugin.version>2.8.1</versions.maven.plugin.version>
|
||||
<spotbugs.maven.plugin.version>4.7.0.0</spotbugs.maven.plugin.version>
|
||||
<versions.maven.plugin.version>2.11.0</versions.maven.plugin.version>
|
||||
|
||||
<!-- testing -->
|
||||
<invoker.mergeUserSettings>false</invoker.mergeUserSettings>
|
||||
|
|
Loading…
Reference in New Issue