diff --git a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java index 9b1278c8bd26..9612d5204e57 100644 --- a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java +++ b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java @@ -26,34 +26,34 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.Authentication; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; import org.eclipse.jetty.client.ConnectionPool; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.DigestAuthentication; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.OutputStreamRequestContent; +import org.eclipse.jetty.client.PathRequestContent; import org.eclipse.jetty.client.ProxyConfiguration; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.client.RoundRobinConnectionPool; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.DigestAuthentication; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.InputStreamRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; -import org.eclipse.jetty.client.util.PathRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -265,11 +265,7 @@ public void listeners() throws Exception .onResponseBegin(response -> { /* ... */ }) .onResponseHeader((response, field) -> true) .onResponseHeaders(response -> { /* ... */ }) - .onResponseContentAsync((response, chunk, demander) -> - { - chunk.release(); - demander.run(); - }) + .onResponseContentAsync((response, chunk, demander) -> demander.run()) .onResponseFailure((response, failure) -> { /* ... */ }) .onResponseSuccess(response -> { /* ... */ }) // Result hook. @@ -505,12 +501,12 @@ private void forwardContent(Response response, Content.Source contentSource) // nor demanded again until the demand callback is invoked. return; } - // Check if the chunk is the terminal one, in which case the + // Check if the chunk is last and empty, in which case the // read/demand loop is done. Demanding again when the terminal // chunk has been read will invoke the demand callback with // the same terminal chunk, so this check must be present to // avoid infinitely demanding and reading the terminal chunk. - if (chunk.isTerminal()) + if (chunk.isLast() && !chunk.hasRemaining()) { chunk.release(); return; @@ -870,13 +866,11 @@ public void getConnectionPool() throws Exception httpClient.start(); ConnectionPool connectionPool = httpClient.getDestinations().stream() - // Cast to HttpDestination. - .map(HttpDestination.class::cast) // Find the destination by filtering on the Origin. .filter(destination -> destination.getOrigin().getAddress().getHost().equals("domain.com")) .findAny() // Get the ConnectionPool. - .map(HttpDestination::getConnectionPool) + .map(Destination::getConnectionPool) .orElse(null); // end::getConnectionPool[] } @@ -901,7 +895,6 @@ public void setConnectionPool() throws Exception transport.setConnectionPoolFactory(destination -> new RoundRobinConnectionPool(destination, maxConnectionsPerDestination, - destination, maxRequestsPerConnection)); // end::setConnectionPool[] } diff --git a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/websocket/WebSocketClientDocs.java b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/websocket/WebSocketClientDocs.java index 8bb09a96c005..03813e57c40c 100644 --- a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/websocket/WebSocketClientDocs.java +++ b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/client/websocket/WebSocketClientDocs.java @@ -19,9 +19,9 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.ee10.websocket.client.JettyUpgradeListener; @@ -175,7 +175,7 @@ public void inspectHTTPResponse() throws Exception JettyUpgradeListener listener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { // Inspect the HTTP response here. } diff --git a/jetty-core/jetty-alpn/jetty-alpn-conscrypt-server/src/test/java/org/eclipse/jetty/alpn/conscrypt/server/ConscryptHTTP2ServerTest.java b/jetty-core/jetty-alpn/jetty-alpn-conscrypt-server/src/test/java/org/eclipse/jetty/alpn/conscrypt/server/ConscryptHTTP2ServerTest.java index 4b716f3a9463..ea7611557068 100644 --- a/jetty-core/jetty-alpn/jetty-alpn-conscrypt-server/src/test/java/org/eclipse/jetty/alpn/conscrypt/server/ConscryptHTTP2ServerTest.java +++ b/jetty-core/jetty-alpn/jetty-alpn-conscrypt-server/src/test/java/org/eclipse/jetty/alpn/conscrypt/server/ConscryptHTTP2ServerTest.java @@ -20,8 +20,8 @@ import org.conscrypt.OpenSSLProvider; import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; diff --git a/jetty-core/jetty-client/src/main/java/module-info.java b/jetty-core/jetty-client/src/main/java/module-info.java index 4eeff64ec280..aa4ddeee2f0b 100644 --- a/jetty-core/jetty-client/src/main/java/module-info.java +++ b/jetty-core/jetty-client/src/main/java/module-info.java @@ -25,11 +25,13 @@ requires static org.eclipse.jetty.jmx; exports org.eclipse.jetty.client; - exports org.eclipse.jetty.client.api; - exports org.eclipse.jetty.client.dynamic; - exports org.eclipse.jetty.client.http; - exports org.eclipse.jetty.client.util; + exports org.eclipse.jetty.client.transport; exports org.eclipse.jetty.client.jmx to org.eclipse.jetty.jmx; + + exports org.eclipse.jetty.client.internal to + org.eclipse.jetty.fcgi.client, + org.eclipse.jetty.http2.client.transport, + org.eclipse.jetty.http3.client.transport; } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AbstractAuthentication.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractAuthentication.java similarity index 93% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AbstractAuthentication.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractAuthentication.java index b01c4a5158df..a3e515215441 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AbstractAuthentication.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractAuthentication.java @@ -11,13 +11,10 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.net.URI; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Authentication; - public abstract class AbstractAuthentication implements Authentication { private final URI uri; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java index 8dbb15a40f86..e773ec072175 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java @@ -25,9 +25,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import org.eclipse.jetty.client.api.Connection; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.util.Attachable; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.Pool; @@ -49,17 +48,15 @@ public abstract class AbstractConnectionPool extends ContainerLifeCycle implemen private final AtomicInteger pending = new AtomicInteger(); private final HttpDestination destination; - private final Callback requester; private final Pool pool; private boolean maximizeConnections; private volatile long maxDurationNanos; private volatile int maxUsage; private volatile int initialMaxMultiplex; - protected AbstractConnectionPool(HttpDestination destination, Pool pool, Callback requester, int initialMaxMultiplex) + protected AbstractConnectionPool(Destination destination, Pool pool, int initialMaxMultiplex) { - this.destination = destination; - this.requester = requester; + this.destination = (HttpDestination)destination; this.pool = pool; this.initialMaxMultiplex = initialMaxMultiplex; addBean(pool); @@ -307,7 +304,7 @@ public boolean accept(Connection connection) protected void proceed() { - requester.succeeded(); + destination.succeeded(); } protected Connection activate() @@ -587,7 +584,7 @@ public void failed(Throwable x) pending.decrementAndGet(); reserved.remove(); completeExceptionally(x); - requester.failed(x); + destination.failed(x); } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java index 1b4fc4175a8d..801d6e13acd0 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -import org.eclipse.jetty.client.api.Connection; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.annotation.ManagedAttribute; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java index 31dcf5f2f56b..c7a3234a7e67 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java @@ -15,7 +15,6 @@ import java.util.Map; -import org.eclipse.jetty.client.api.Connection; import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AsyncRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncRequestContent.java similarity index 94% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AsyncRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncRequestContent.java index a0984b3caa14..ff7e8265d65a 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/AsyncRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncRequestContent.java @@ -11,12 +11,11 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.nio.ByteBuffer; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.io.content.AsyncContent; import org.eclipse.jetty.util.Callback; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Authentication.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Authentication.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Authentication.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Authentication.java index c3b734d1dadd..d837d4a9927d 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Authentication.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Authentication.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; import java.net.URI; import java.util.Map; @@ -54,7 +54,7 @@ public interface Authentication /** * Executes the authentication mechanism for the given request, returning a {@link Result} that can be - * used to actually authenticate the request via {@link org.eclipse.jetty.client.api.Authentication.Result#apply(Request)}. + * used to actually authenticate the request via {@link Authentication.Result#apply(Request)}. *

* If a request for {@code "/secure"} returns a {@link Result}, then the result may be used for other * requests such as {@code "/secure/foo"} or {@code "/secure/bar"}, unless those resources are protected @@ -136,7 +136,7 @@ public HttpHeader getHeader() } /** - * {@link Result} holds the information needed to authenticate a {@link Request} via {@link org.eclipse.jetty.client.api.Authentication.Result#apply(org.eclipse.jetty.client.api.Request)}. + * {@link Result} holds the information needed to authenticate a {@link Request} via {@link Authentication.Result#apply(Request)}. */ public static interface Result { diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java index ddf7cf0765f0..e9894dbe3e73 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java @@ -23,14 +23,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.Authentication.HeaderInfo; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.Authentication.HeaderInfo; +import org.eclipse.jetty.client.internal.HttpContentResponse; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; @@ -42,13 +39,13 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler { public static final int DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024; - public static final Logger LOG = LoggerFactory.getLogger(AuthenticationProtocolHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(AuthenticationProtocolHandler.class); + private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?[a-zA-Z0-9\\-._~+/]+=*)|(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:(?.*)))"); + private final HttpClient client; private final int maxContentLength; private final ResponseNotifier notifier; - private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?[a-zA-Z0-9\\-._~+/]+=*)|(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:(?.*)))"); - protected AuthenticationProtocolHandler(HttpClient client, int maxContentLength) { this.client = client; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationStore.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationStore.java index e4b0e866d732..8aa76c3d19a1 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationStore.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; import java.net.URI; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BasicAuthentication.java similarity index 92% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BasicAuthentication.java index adace6017b1f..c199dcc74e20 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BasicAuthentication.java @@ -11,17 +11,13 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Base64; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.util.Attributes; @@ -68,7 +64,7 @@ public Result authenticate(Request request, ContentResponse response, HeaderInfo * Basic authentication result. *

* Application may utilize this class directly via - * {@link org.eclipse.jetty.client.api.AuthenticationStore#addAuthenticationResult(Result)} + * {@link AuthenticationStore#addAuthenticationResult(Result)} * to perform preemptive authentication, that is immediately * sending the authorization header based on the fact that the * URI is known to require authentication and that username diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BufferingResponseListener.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BufferingResponseListener.java similarity index 96% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BufferingResponseListener.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BufferingResponseListener.java index e9d82a30d0c0..8bcb11f256b8 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BufferingResponseListener.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BufferingResponseListener.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -20,10 +20,7 @@ import java.nio.charset.StandardCharsets; import java.util.Locale; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Response.Listener; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response.Listener; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; @@ -112,6 +109,8 @@ public void onHeaders(Response response) public void onContent(Response response, ByteBuffer content) { int length = content.remaining(); + if (length == 0) + return; if (length > BufferUtil.space(buffer)) { int remaining = buffer == null ? 0 : buffer.remaining(); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/ByteBufferRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ByteBufferRequestContent.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/ByteBufferRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ByteBufferRequestContent.java index d3bedf6b5953..8beedc7f2122 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/ByteBufferRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ByteBufferRequestContent.java @@ -11,13 +11,12 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.nio.ByteBuffer; import java.util.Collection; import java.util.List; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.io.content.ByteBufferContentSource; /** diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BytesRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BytesRequestContent.java similarity index 92% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BytesRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BytesRequestContent.java index 30993e8ab9c4..c242b28f4cb7 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/BytesRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/BytesRequestContent.java @@ -11,13 +11,11 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.nio.ByteBuffer; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.Request; - /** * A {@link Request.Content} for byte arrays. */ diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Connection.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Connection.java similarity index 97% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Connection.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Connection.java index bcb7c29e3a85..2a2e49a32861 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Connection.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Connection.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; import java.io.Closeable; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java index f146d9dc2d37..2ce6f1832b10 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java @@ -16,8 +16,6 @@ import java.io.Closeable; import java.util.concurrent.CompletableFuture; -import org.eclipse.jetty.client.api.Connection; - /** *

Client-side connection pool abstraction.

*/ @@ -102,7 +100,7 @@ interface Factory * @param destination the destination to create the ConnectionPool for * @return the newly created ConnectionPool */ - ConnectionPool newConnectionPool(HttpDestination destination); + ConnectionPool newConnectionPool(Destination destination); } /** diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentDecoder.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentDecoder.java index 40d7d507bcec..537a74f540ea 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentDecoder.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentDecoder.java @@ -14,6 +14,12 @@ package org.eclipse.jetty.client; import java.nio.ByteBuffer; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.http.HttpHeader; /** * {@link ContentDecoder} decodes content bytes of a response. @@ -89,4 +95,35 @@ public int hashCode() */ public abstract ContentDecoder newContentDecoder(); } + + public static class Factories implements Iterable + { + private final Map factories = new LinkedHashMap<>(); + private HttpField acceptEncodingField; + + public HttpField getAcceptEncodingField() + { + return acceptEncodingField; + } + + @Override + public Iterator iterator() + { + return factories.values().iterator(); + } + + public void clear() + { + factories.clear(); + acceptEncodingField = null; + } + + public Factory put(Factory factory) + { + Factory result = factories.put(factory.getEncoding(), factory); + String value = String.join(",", factories.keySet()); + acceptEncodingField = new HttpField(HttpHeader.ACCEPT_ENCODING, value); + return result; + } + } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/ContentResponse.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentResponse.java similarity index 66% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/ContentResponse.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentResponse.java index 3f856c698e72..72baaa474e01 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/ContentResponse.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContentResponse.java @@ -11,13 +11,27 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; + +import org.eclipse.jetty.client.internal.HttpContentResponse; /** * A specialized {@link Response} that can hold a limited content in memory. */ public interface ContentResponse extends Response { + /** + * @param response the Response with status code and headers + * @param content the content bytes associated to the response + * @param mediaType the media type of the content bytes + * @param encoding the encoding of the content bytes + * @return a new ContentResponse from the given arguments + */ + static ContentResponse from(Response response, byte[] content, String mediaType, String encoding) + { + return new HttpContentResponse(response, content, mediaType, encoding); + } + /** * @return the media type of the content, such as "text/html" or "application/octet-stream" */ diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContinueProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContinueProtocolHandler.java index eb23278b07e0..d62b59320342 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContinueProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ContinueProtocolHandler.java @@ -15,10 +15,11 @@ import java.util.List; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.internal.HttpContentResponse; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Destination.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Destination.java new file mode 100644 index 000000000000..a4ab82b2eff6 --- /dev/null +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Destination.java @@ -0,0 +1,95 @@ +// +// ======================================================================== +// 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.client; + +import org.eclipse.jetty.util.FuturePromise; +import org.eclipse.jetty.util.Promise; + +/** + *

A {@link Destination} represents the receiver of HTTP requests, and it is + * identified by an {@link Origin}.

+ *

{@link Destination} holds a pool of {@link Connection}s, but allows to create unpooled + * connections if the application wants full control over connection management via + * {@link #newConnection(Promise)}.

+ *

{@link Destination}s may be obtained via {@link HttpClient#resolveDestination(Request)}.

+ */ +public interface Destination +{ + /** + * @return the origin of this destination + */ + Origin getOrigin(); + + /** + * @return whether the communication with the destination is secure + */ + boolean isSecure(); + + /** + * @return the proxy associated with this destination, + * or {@code null} if there is no proxy + */ + ProxyConfiguration.Proxy getProxy(); + + /** + * @return the connection pool associated with this destination + */ + ConnectionPool getConnectionPool(); + + /** + * @return the {@code HttpClient} that manages this destination + */ + HttpClient getHttpClient(); + + /** + * Creates asynchronously a new, unpooled, {@link Connection} that will be returned + * at a later time through the given {@link Promise}. + *

+ * Use {@link FuturePromise} to wait for the connection: + *

{@code
+     * Destination destination = ...;
+     * FuturePromise futureConnection = new FuturePromise<>();
+     * destination.newConnection(futureConnection);
+     * Connection connection = futureConnection.get(5, TimeUnit.SECONDS);
+     * }
+ * + * @param promise the promise of a new, unpooled, {@link Connection} + */ + void newConnection(Promise promise); + + /** + *

Sends the given request to this destination.

+ *

You can use this method to send the request to a specific + * destination that may be different from the request authority.

+ *

For example when {@link HttpClient} is used in a proxy, it may + * receive a request with authority {@code yourserver.com} but the + * proxy logic may want to forward the request to a specific backend + * server, say {@code backend01}, therefore:

+ *
{@code
+     * // Resolve the backend destination.
+     * Origin backendOrigin = new Origin(backendScheme, "backend01", backendPort);
+     * Destination backendDestination = httpClient.resolveDestination(backendOrigin);
+     *
+     * // Create a request with the original authority.
+     * Request request = httpClient.newRequest("https://yourserver.com/path");
+     *
+     * // Send the request to the specific backend.
+     * backendDestination.send(request, result -> { ... });
+     * }
+ * + * @param request the request to send to this destination + * @param listener the listener that receives response events + */ + void send(Request request, Response.CompleteListener listener); +} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DigestAuthentication.java similarity index 97% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DigestAuthentication.java index 62440a2ebafb..e315988f3910 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/DigestAuthentication.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DigestAuthentication.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.net.URI; import java.nio.charset.StandardCharsets; @@ -25,10 +25,6 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.util.Attributes; import org.eclipse.jetty.util.StringUtil; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java index e9f17b1c80c9..b51992a3a4eb 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java @@ -13,15 +13,14 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Pool; import org.eclipse.jetty.util.annotation.ManagedObject; @ManagedObject public class DuplexConnectionPool extends AbstractConnectionPool { - public DuplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester) + public DuplexConnectionPool(Destination destination, int maxConnections) { - super(destination, new Pool<>(Pool.StrategyType.FIRST, maxConnections, false), requester, 1); + super(destination, new Pool<>(Pool.StrategyType.FIRST, maxConnections, false), 1); } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/EarlyHintsProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/EarlyHintsProtocolHandler.java index be6cbf0f2a60..f4357eaf24ab 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/EarlyHintsProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/EarlyHintsProtocolHandler.java @@ -15,10 +15,11 @@ import java.util.List; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.internal.HttpContentResponse; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FormRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FormRequestContent.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FormRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FormRequestContent.java index 38972589e1d9..5c8e1d2af1eb 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FormRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FormRequestContent.java @@ -11,13 +11,12 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.util.Fields; /** diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FutureResponseListener.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FutureResponseListener.java similarity index 93% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FutureResponseListener.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FutureResponseListener.java index 858d7042c781..55b1b06971be 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/FutureResponseListener.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/FutureResponseListener.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; @@ -21,10 +21,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; -import org.eclipse.jetty.client.HttpContentResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.internal.HttpContentResponse; /** * A {@link BufferingResponseListener} that is also a {@link Future}, to allow applications diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 1acff31e5a2d..881b797fdbf1 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -25,14 +25,11 @@ import java.nio.channels.SocketChannel; import java.time.Duration; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; @@ -40,14 +37,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.FormRequestContent; +import org.eclipse.jetty.client.internal.HttpAuthenticationStore; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpCompliance; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; @@ -124,7 +118,7 @@ public class HttpClient extends ContainerLifeCycle private final ConcurrentMap destinations = new ConcurrentHashMap<>(); private final ProtocolHandlers handlers = new ProtocolHandlers(); private final List requestListeners = new ArrayList<>(); - private final Set decoderFactories = new ContentDecoderFactorySet(); + private final ContentDecoder.Factories decoderFactories = new ContentDecoder.Factories(); private final ProxyConfiguration proxyConfig = new ProxyConfiguration(); private final HttpClientTransport transport; private final ClientConnector connector; @@ -140,9 +134,7 @@ public class HttpClient extends ContainerLifeCycle private int responseBufferSize = 16384; private int maxRedirects = 8; private long addressResolutionTimeout = 15000; - private boolean tcpNoDelay = true; private boolean strictEventOrdering = false; - private HttpField encodingField; private long destinationIdleTimeout; private String name = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()); private HttpCompliance httpCompliance = HttpCompliance.RFC7230; @@ -232,7 +224,7 @@ protected void doStart() throws Exception handlers.put(new ProxyAuthenticationProtocolHandler(this)); handlers.put(new UpgradeProtocolHandler()); - decoderFactories.add(new GZIPContentDecoder.Factory(byteBufferPool)); + decoderFactories.put(new GZIPContentDecoder.Factory(byteBufferPool)); cookieManager = newCookieManager(); cookieStore = cookieManager.getCookieStore(); @@ -264,13 +256,7 @@ protected void doStop() throws Exception decoderFactories.clear(); handlers.clear(); - - for (HttpDestination destination : destinations.values()) - { - destination.close(); - } destinations.clear(); - requestListeners.clear(); authenticationStore.clearAuthentications(); authenticationStore.clearAuthenticationResults(); @@ -279,10 +265,10 @@ protected void doStop() throws Exception } /** - * Returns a non thread-safe list of {@link org.eclipse.jetty.client.api.Request.Listener}s that can be modified before + * Returns a non thread-safe list of {@link Request.Listener}s that can be modified before * performing requests. * - * @return a list of {@link org.eclipse.jetty.client.api.Request.Listener} that can be used to add and remove listeners + * @return a list of {@link Request.Listener} that can be used to add and remove listeners */ public List getRequestListeners() { @@ -308,20 +294,23 @@ public void setCookieStore(CookieStore cookieStore) this.cookieManager = newCookieManager(); } - /** - * Keep this method package-private because its interface is so ugly - * that we really don't want to expose it more than strictly needed. - * - * @return the cookie manager - */ - CookieManager getCookieManager() - { - return cookieManager; - } - - Sweeper getDestinationSweeper() + public void putCookie(URI uri, HttpField field) { - return destinationSweeper; + try + { + String value = field.getValue(); + if (value != null) + { + Map> header = new HashMap<>(1); + header.put(field.getHeader().asString(), List.of(value)); + cookieManager.put(uri, header); + } + } + catch (IOException x) + { + if (LOG.isDebugEnabled()) + LOG.debug("Unable to store cookies {} from {}", field, uri, x); + } } /** @@ -348,7 +337,7 @@ public void setAuthenticationStore(AuthenticationStore authenticationStore) * * @return a set of {@link ContentDecoder.Factory} that can be used to add and remove content decoder factories */ - public Set getContentDecoderFactories() + public ContentDecoder.Factories getContentDecoderFactories() { return decoderFactories; } @@ -474,9 +463,9 @@ public Request newRequest(URI uri) return newHttpRequest(newConversation(), uri); } - protected Request copyRequest(HttpRequest oldRequest, URI newURI) + protected Request copyRequest(Request oldRequest, URI newURI) { - HttpRequest newRequest = newHttpRequest(oldRequest.getConversation(), newURI); + HttpRequest newRequest = newHttpRequest(((HttpRequest)oldRequest).getConversation(), newURI); newRequest.method(oldRequest.getMethod()) .version(oldRequest.getVersion()) .body(oldRequest.getBody()) @@ -510,7 +499,7 @@ protected Request copyRequest(HttpRequest oldRequest, URI newURI) return newRequest; } - protected HttpRequest newHttpRequest(HttpConversation conversation, URI uri) + private HttpRequest newHttpRequest(HttpConversation conversation, URI uri) { return new HttpRequest(this, conversation, checkHost(uri)); } @@ -534,14 +523,14 @@ private URI checkHost(URI uri) public Destination resolveDestination(Request request) { HttpClientTransport transport = getTransport(); - Origin origin = transport.newOrigin((HttpRequest)request); - HttpDestination destination = resolveDestination(origin); + Origin origin = transport.newOrigin(request); + Destination destination = resolveDestination(origin); if (LOG.isDebugEnabled()) LOG.debug("Resolved {} for {}", destination, request); return destination; } - public Origin createOrigin(HttpRequest request, Origin.Protocol protocol) + public Origin createOrigin(Request request, Origin.Protocol protocol) { String scheme = request.getScheme(); if (!HttpScheme.HTTP.is(scheme) && !HttpScheme.HTTPS.is(scheme) && @@ -561,15 +550,17 @@ public Origin createOrigin(HttpRequest request, Origin.Protocol protocol) * @param origin the origin that identifies the destination * @return the destination for the given origin */ - public HttpDestination resolveDestination(Origin origin) + public Destination resolveDestination(Origin origin) { return destinations.compute(origin, (k, v) -> { if (v == null || v.stale()) { - HttpDestination newDestination = getTransport().newHttpDestination(k); + HttpDestination newDestination = (HttpDestination)getTransport().newDestination(k); // Start the destination before it's published to other threads. addManaged(newDestination); + if (destinationSweeper != null) + destinationSweeper.offer(newDestination); if (LOG.isDebugEnabled()) LOG.debug("Created {}; existing: '{}'", newDestination, v); return newDestination; @@ -578,10 +569,13 @@ public HttpDestination resolveDestination(Origin origin) }); } - protected boolean removeDestination(HttpDestination destination) + public boolean removeDestination(Destination destination) { - boolean removed = destinations.remove(destination.getOrigin(), destination); + HttpDestination httpDestination = (HttpDestination)destination; + boolean removed = destinations.remove(destination.getOrigin(), httpDestination); removeBean(destination); + if (destinationSweeper != null) + destinationSweeper.remove(httpDestination); if (LOG.isDebugEnabled()) LOG.debug("Removed {}; result: {}", destination, removed); return removed; @@ -595,13 +589,7 @@ public List getDestinations() return new ArrayList<>(destinations.values()); } - protected void send(HttpRequest request, List listeners) - { - HttpDestination destination = (HttpDestination)resolveDestination(request); - destination.send(request, listeners); - } - - protected void newConnection(HttpDestination destination, Promise promise) + public void newConnection(Destination destination, Promise promise) { // Multiple threads may access the map, especially with DEBUG logging enabled. Map context = new ConcurrentHashMap<>(); @@ -611,8 +599,9 @@ protected void newConnection(HttpDestination destination, Promise pr List protocols = protocol != null ? protocol.getProtocols() : List.of("http/1.1"); context.put(ClientConnector.APPLICATION_PROTOCOLS_CONTEXT_KEY, protocols); - Origin.Address address = destination.getConnectAddress(); - resolver.resolve(address.getHost(), address.getPort(), new Promise<>() + ProxyConfiguration.Proxy proxy = destination.getProxy(); + Origin.Address address = proxy == null ? destination.getOrigin().getAddress() : proxy.getAddress(); + getSocketAddressResolver().resolve(address.getHost(), address.getPort(), new Promise<>() { @Override public void succeeded(List socketAddresses) @@ -655,7 +644,7 @@ public ProtocolHandlers getProtocolHandlers() return handlers; } - protected ProtocolHandler findProtocolHandler(Request request, Response response) + public ProtocolHandler findProtocolHandler(Request request, Response response) { return handlers.find(request, response); } @@ -1002,7 +991,7 @@ public boolean isStrictEventOrdering() * Whether request/response events must be strictly ordered with respect to connection usage. *

* From the point of view of connection usage, the connection can be reused just before the - * "complete" event notified to {@link org.eclipse.jetty.client.api.Response.CompleteListener}s + * "complete" event notified to {@link Response.CompleteListener}s * (but after the "success" event). *

* When a request/response exchange is completing, the destination may have another request @@ -1146,11 +1135,6 @@ public ProxyConfiguration getProxyConfiguration() return proxyConfig; } - protected HttpField getAcceptEncodingField() - { - return encodingField; - } - public static int normalizePort(String scheme, int port) { if (port > 0) @@ -1168,145 +1152,10 @@ public static boolean isSchemeSecure(String scheme) return HttpScheme.HTTPS.is(scheme) || HttpScheme.WSS.is(scheme); } - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { if (sslContextFactory == null) sslContextFactory = getSslContextFactory(); return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory); } - - private class ContentDecoderFactorySet implements Set - { - private final Set set = new HashSet<>(); - - @Override - public boolean add(ContentDecoder.Factory e) - { - boolean result = set.add(e); - invalidate(); - return result; - } - - @Override - public boolean addAll(Collection c) - { - boolean result = set.addAll(c); - invalidate(); - return result; - } - - @Override - public boolean remove(Object o) - { - boolean result = set.remove(o); - invalidate(); - return result; - } - - @Override - public boolean removeAll(Collection c) - { - boolean result = set.removeAll(c); - invalidate(); - return result; - } - - @Override - public boolean retainAll(Collection c) - { - boolean result = set.retainAll(c); - invalidate(); - return result; - } - - @Override - public void clear() - { - set.clear(); - invalidate(); - } - - @Override - public int size() - { - return set.size(); - } - - @Override - public boolean isEmpty() - { - return set.isEmpty(); - } - - @Override - public boolean contains(Object o) - { - return set.contains(o); - } - - @Override - public boolean containsAll(Collection c) - { - return set.containsAll(c); - } - - @Override - public Iterator iterator() - { - Iterator iterator = set.iterator(); - return new Iterator<>() - { - @Override - public boolean hasNext() - { - return iterator.hasNext(); - } - - @Override - public ContentDecoder.Factory next() - { - return iterator.next(); - } - - @Override - public void remove() - { - iterator.remove(); - invalidate(); - } - }; - } - - @Override - public Object[] toArray() - { - return set.toArray(); - } - - @Override - public T[] toArray(T[] a) - { - return set.toArray(a); - } - - private void invalidate() - { - if (set.isEmpty()) - { - encodingField = null; - } - else - { - StringBuilder value = new StringBuilder(); - for (Iterator iterator = set.iterator(); iterator.hasNext(); ) - { - ContentDecoder.Factory decoderFactory = iterator.next(); - value.append(decoderFactory.getEncoding()); - if (iterator.hasNext()) - value.append(","); - } - encodingField = new HttpField(HttpHeader.ACCEPT_ENCODING, value.toString()); - } - } - } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java index eab3325ddee8..c5cfeac0cfe1 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java @@ -17,6 +17,7 @@ import java.net.SocketAddress; import java.util.Map; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.ClientConnectionFactory; /** @@ -52,7 +53,7 @@ public interface HttpClientTransport extends ClientConnectionFactory * @param request the request that triggers the creation of the Origin * @return an Origin that identifies a destination */ - public Origin newOrigin(HttpRequest request); + public Origin newOrigin(Request request); /** * Creates a new, transport-specific, {@link HttpDestination} object. @@ -63,7 +64,7 @@ public interface HttpClientTransport extends ClientConnectionFactory * @param origin the destination origin * @return a new, transport-specific, {@link HttpDestination} object */ - public HttpDestination newHttpDestination(Origin origin); + public Destination newDestination(Origin origin); /** * Establishes a physical connection to the given {@code address}. diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java index 9d32b20ec825..1b8e63fb4745 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java @@ -21,11 +21,10 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.TunnelRequest; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpScheme; @@ -142,7 +141,7 @@ private org.eclipse.jetty.io.Connection newProxyConnection(EndPoint endPoint, Ma // Replace the destination with the proxy destination. HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); HttpClient client = destination.getHttpClient(); - HttpDestination proxyDestination = client.resolveDestination(getOrigin()); + Destination proxyDestination = client.resolveDestination(getOrigin()); context.put(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY, proxyDestination); try { @@ -194,7 +193,8 @@ public void failed(Throwable x) private void tunnel(HttpDestination destination, Connection connection) { String target = destination.getOrigin().getAddress().asString(); - Origin.Address proxyAddress = destination.getConnectAddress(); + ProxyConfiguration.Proxy proxy = destination.getProxy(); + Origin.Address proxyAddress = proxy.getAddress(); HttpClient httpClient = destination.getHttpClient(); long connectTimeout = httpClient.getConnectTimeout(); Request connect = new TunnelRequest(httpClient, proxyAddress) @@ -204,7 +204,6 @@ private void tunnel(HttpDestination destination, Connection connection) // Use the connect timeout as a total timeout, // since this request is to "connect" to the server. .timeout(connectTimeout, TimeUnit.MILLISECONDS); - ProxyConfiguration.Proxy proxy = destination.getProxy(); if (proxy.isSecure()) connect.scheme(HttpScheme.HTTPS.asString()); @@ -223,7 +222,7 @@ private void tunnelSucceeded(EndPoint endPoint) // Don't want to do DNS resolution here. InetSocketAddress address = InetSocketAddress.createUnresolved(destination.getHost(), destination.getPort()); context.put(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY, address); - connectionFactory = destination.newSslClientConnectionFactory(null, connectionFactory); + connectionFactory = destination.getHttpClient().newSslClientConnectionFactory(null, connectionFactory); } var oldConnection = endPoint.getConnection(); var newConnection = connectionFactory.newConnection(endPoint, context); @@ -360,12 +359,4 @@ private void setEndPoint(EndPoint endPoint) conversation.setAttribute(EndPoint.class.getName(), endPoint); } } - - public static class TunnelRequest extends HttpRequest - { - private TunnelRequest(HttpClient client, Origin.Address address) - { - super(client, new HttpConversation(), URI.create("http://" + address.asString())); - } - } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java index 5cd90a3aaa58..036948b18bb3 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRedirector.java @@ -24,10 +24,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.internal.HttpContentResponse; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequestException.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequestException.java index 8f65dcc0007f..ff1bc1a6b6a6 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequestException.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequestException.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Request; - public class HttpRequestException extends RuntimeException { private final Request request; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponseException.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponseException.java index 8e68e99af54d..510fe08158c8 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponseException.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponseException.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Response; - public class HttpResponseException extends RuntimeException { private final Response response; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpUpgrader.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpUpgrader.java index acd3884db04c..443f18b57020 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpUpgrader.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpUpgrader.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; @@ -31,13 +30,19 @@ */ public interface HttpUpgrader { + /** + *

The request attribute key for the upgrade protocol, + * used by the HTTP/2 extended CONNECT mechanism.

+ */ + public static final String PROTOCOL_ATTRIBUTE = HttpUpgrader.class.getName() + ".protocol"; + /** *

Prepares the request for the upgrade, for example by setting the HTTP method * or by setting HTTP headers required for the upgrade.

* * @param request the request to prepare */ - public void prepare(HttpRequest request); + public void prepare(Request request); /** *

Upgrades the given {@code endPoint} to a different protocol.

@@ -48,7 +53,7 @@ public interface HttpUpgrader * @param endPoint the EndPoint to upgrade * @param callback a callback to notify of the success or failure of the upgrade */ - public void upgrade(HttpResponse response, EndPoint endPoint, Callback callback); + public void upgrade(Response response, EndPoint endPoint, Callback callback); /** *

A factory for {@link HttpUpgrader}s.

diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamRequestContent.java similarity index 96% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamRequestContent.java index 860dad43d8bc..f9be0ff11504 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamRequestContent.java @@ -11,11 +11,10 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.InputStream; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.content.InputStreamContentSource; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamResponseListener.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamResponseListener.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamResponseListener.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamResponseListener.java index 27d6c521ea8d..ffaca7eb256f 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamResponseListener.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/InputStreamResponseListener.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.IOException; import java.io.InputStream; @@ -30,10 +30,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Response.Listener; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response.Listener; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.thread.AutoLock; @@ -105,31 +102,26 @@ public void onContent(Response response, Content.Chunk chunk, Runnable demander) { if (LOG.isDebugEnabled()) LOG.debug("Skipped empty chunk {}", chunk); - chunk.release(); demander.run(); return; } - boolean closed; try (AutoLock.WithCondition l = lock.lock()) { - closed = this.closed; if (!closed) { if (LOG.isDebugEnabled()) LOG.debug("Queueing chunk {}", chunk); + chunk.retain(); chunkCallbacks.add(new ChunkCallback(chunk, demander, response::abort)); l.signalAll(); + return; } } - if (closed) - { - if (LOG.isDebugEnabled()) - LOG.debug("InputStream closed, ignored chunk {}", chunk); - chunk.release(); - response.abort(new AsynchronousCloseException()); - } + if (LOG.isDebugEnabled()) + LOG.debug("InputStream closed, ignored chunk {}", chunk); + response.abort(new AsynchronousCloseException()); } @Override diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java index de471dc7011d..46310ccb3c66 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.LeakDetector; import org.eclipse.jetty.util.component.LifeCycle; import org.slf4j.Logger; @@ -33,9 +31,9 @@ protected void leaked(LeakInfo leakInfo) } }; - public LeakTrackingConnectionPool(HttpDestination destination, int maxConnections, Callback requester) + public LeakTrackingConnectionPool(Destination destination, int maxConnections) { - super(destination, maxConnections, requester); + super(destination, maxConnections); addBean(leakDetector); } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiPartRequestContent.java similarity index 97% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiPartRequestContent.java index 9018b9ea472e..88ea11d45dce 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiPartRequestContent.java @@ -11,9 +11,8 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.MultiPart; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java index f3ae15d08344..d6ac4b6c3775 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Pool; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; @@ -21,12 +20,12 @@ @ManagedObject public class MultiplexConnectionPool extends AbstractConnectionPool { - public MultiplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int initialMaxMultiplex) + public MultiplexConnectionPool(Destination destination, int maxConnections, int initialMaxMultiplex) { - this(destination, Pool.StrategyType.FIRST, maxConnections, false, requester, initialMaxMultiplex); + this(destination, Pool.StrategyType.FIRST, maxConnections, false, initialMaxMultiplex); } - protected MultiplexConnectionPool(HttpDestination destination, Pool.StrategyType strategy, int maxConnections, boolean cache, Callback requester, int initialMaxMultiplex) + protected MultiplexConnectionPool(Destination destination, Pool.StrategyType strategy, int maxConnections, boolean cache, int initialMaxMultiplex) { super(destination, new Pool<>(strategy, maxConnections, cache, connection -> { @@ -34,7 +33,7 @@ protected MultiplexConnectionPool(HttpDestination destination, Pool.StrategyType if (connection instanceof MaxMultiplexable maxMultiplexable) maxMultiplex = maxMultiplexable.getMaxMultiplex(); return maxMultiplex; - }), requester, initialMaxMultiplex); + }), initialMaxMultiplex); } @Override diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Origin.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Origin.java index d0c209b0823a..d9b44ffb19ef 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Origin.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Origin.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Objects; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.HostPort; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/OutputStreamRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/OutputStreamRequestContent.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/OutputStreamRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/OutputStreamRequestContent.java index 832f347a1c59..d742d585b9e7 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/OutputStreamRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/OutputStreamRequestContent.java @@ -11,12 +11,10 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.OutputStream; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.io.content.OutputStreamContentSource; /** diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/PathRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/PathRequestContent.java similarity index 96% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/PathRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/PathRequestContent.java index 3c404ffb112c..dc9ee8ed059e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/PathRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/PathRequestContent.java @@ -11,12 +11,11 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.IOException; import java.nio.file.Path; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.content.PathContentSource; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProcessingProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProcessingProtocolHandler.java index 8ca7f583f281..42cbbafdd9a7 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProcessingProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProcessingProtocolHandler.java @@ -15,10 +15,11 @@ import java.util.List; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.internal.HttpContentResponse; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandler.java index ef71d0368cc0..1db5bebc1e1f 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandler.java @@ -13,9 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; - /** *

A protocol handler performs HTTP protocol operations on * behalf of the application, typically like a browser would.

diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandlers.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandlers.java index 816d1470deae..c8be524d6d51 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandlers.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProtocolHandlers.java @@ -17,8 +17,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.util.component.Dumpable; /** diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyAuthenticationProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyAuthenticationProtocolHandler.java index c698375c9b62..6d41856860ca 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyAuthenticationProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyAuthenticationProtocolHandler.java @@ -15,8 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java index f24001c83588..8e9164d1969b 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java @@ -26,6 +26,7 @@ import java.util.Objects; import java.util.concurrent.Executor; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.Connection; @@ -79,7 +80,7 @@ protected ProxyProtocolConnection newProxyProtocolConnection(EndPoint endPoint, /** *

PROXY protocol version 1 metadata holder to be used in conjunction - * with {@link org.eclipse.jetty.client.api.Request#tag(Object)}.

+ * with {@link Request#tag(Object)}.

*

Instances of this class are associated to a destination so that * all connections of that destination will initiate the communication * with the PROXY protocol version 1 bytes specified by this metadata.

@@ -228,7 +229,7 @@ protected ProxyProtocolConnection newProxyProtocolConnection(EndPoint endPoint, /** *

PROXY protocol version 2 metadata holder to be used in conjunction - * with {@link org.eclipse.jetty.client.api.Request#tag(Object)}.

+ * with {@link Request#tag(Object)}.

*

Instances of this class are associated to a destination so that * all connections of that destination will initiate the communication * with the PROXY protocol version 2 bytes specified by this metadata.

@@ -461,7 +462,7 @@ public Connection newConnection(EndPoint endPoint, Map context) protected abstract static class ProxyProtocolConnection extends AbstractConnection implements Callback { - protected static final Logger LOG = LoggerFactory.getLogger(ProxyProtocolConnection.class); + static final Logger LOG = LoggerFactory.getLogger(ProxyProtocolConnection.class); private final ClientConnectionFactory factory; private final Map context; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RandomConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RandomConnectionPool.java index 579a9409c64d..7aa2e33dacc3 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RandomConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RandomConnectionPool.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Pool; import org.eclipse.jetty.util.annotation.ManagedObject; @@ -24,8 +23,8 @@ @ManagedObject public class RandomConnectionPool extends MultiplexConnectionPool { - public RandomConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplex) + public RandomConnectionPool(Destination destination, int maxConnections, int maxMultiplex) { - super(destination, Pool.StrategyType.RANDOM, maxConnections, false, requester, maxMultiplex); + super(destination, Pool.StrategyType.RANDOM, maxConnections, false, maxMultiplex); } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectProtocolHandler.java index 8218000e10cc..34d2bcb068ac 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectProtocolHandler.java @@ -13,9 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Request.java similarity index 99% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Request.java index 352f473dd883..41170ddc6feb 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Request.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; import java.io.IOException; import java.net.HttpCookie; @@ -30,8 +30,6 @@ import java.util.function.Consumer; import java.util.function.Supplier; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.util.InputStreamResponseListener; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpVersion; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Response.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Response.java index 42f1616f4bdf..832bbeffe0a6 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Response.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Response.java @@ -11,14 +11,13 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; import java.nio.ByteBuffer; import java.util.EventListener; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.eclipse.jetty.client.util.BufferingResponseListener; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpVersion; @@ -44,7 +43,7 @@ public interface Response /** * @param listenerClass the listener class * @param the type of class - * @return the response listener passed to {@link org.eclipse.jetty.client.api.Request#send(org.eclipse.jetty.client.api.Response.CompleteListener)} + * @return the response listener passed to {@link Request#send(Response.CompleteListener)} */ List getListeners(Class listenerClass); @@ -156,12 +155,10 @@ default void onContent(Response response, Content.Chunk chunk, Runnable demander try { onContent(response, chunk.getByteBuffer()); - chunk.release(); demander.run(); } catch (Throwable x) { - chunk.release(); response.abort(x); } } @@ -191,10 +188,22 @@ default void onContentSource(Response response, Content.Source contentSource) response.abort(error.getCause()); return; } - if (chunk.isTerminal()) + if (chunk.isLast() && !chunk.hasRemaining()) + { + chunk.release(); return; + } - onContent(response, chunk, () -> contentSource.demand(demandCallback)); + try + { + onContent(response, chunk, () -> contentSource.demand(demandCallback)); + chunk.release(); + } + catch (Throwable x) + { + chunk.release(); + response.abort(x); + } } } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Result.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Result.java index bb7ca0363fd7..4683ff3a0aae 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Result.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client; /** * The result of a request / response exchange, containing the {@link Request}, the {@link Response} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RoundRobinConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RoundRobinConnectionPool.java index b18205b77702..3e7fa43381e1 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RoundRobinConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RoundRobinConnectionPool.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Pool; import org.eclipse.jetty.util.annotation.ManagedObject; @@ -44,14 +43,14 @@ @ManagedObject public class RoundRobinConnectionPool extends MultiplexConnectionPool { - public RoundRobinConnectionPool(HttpDestination destination, int maxConnections, Callback requester) + public RoundRobinConnectionPool(Destination destination, int maxConnections) { - this(destination, maxConnections, requester, 1); + this(destination, maxConnections, 1); } - public RoundRobinConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplex) + public RoundRobinConnectionPool(Destination destination, int maxConnections, int maxMultiplex) { - super(destination, Pool.StrategyType.ROUND_ROBIN, maxConnections, false, requester, maxMultiplex); + super(destination, Pool.StrategyType.ROUND_ROBIN, maxConnections, false, maxMultiplex); // If there are queued requests and connections get // closed due to idle timeout or overuse, we want to // aggressively try to open new connections to replace diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/SPNEGOAuthentication.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SPNEGOAuthentication.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/SPNEGOAuthentication.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SPNEGOAuthentication.java index 3d791938090b..6c336f448050 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/SPNEGOAuthentication.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SPNEGOAuthentication.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.io.IOException; import java.net.URI; @@ -30,10 +30,6 @@ import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.util.Attributes; import org.ietf.jgss.GSSContext; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java index 212653c60619..6b61ecff73b7 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java @@ -23,7 +23,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.jetty.client.api.Connection; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnector; @@ -207,7 +207,7 @@ private void tunnel() context.put(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY, address); ClientConnectionFactory connectionFactory = this.connectionFactory; if (destination.isSecure()) - connectionFactory = destination.newSslClientConnectionFactory(null, connectionFactory); + connectionFactory = destination.getHttpClient().newSslClientConnectionFactory(null, connectionFactory); org.eclipse.jetty.io.Connection newConnection = connectionFactory.newConnection(getEndPoint(), context); getEndPoint().upgrade(newConnection); if (LOG.isDebugEnabled()) diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/StringRequestContent.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/StringRequestContent.java similarity index 94% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/StringRequestContent.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/StringRequestContent.java index 8ded9985bd5d..b8a243b0a50e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/StringRequestContent.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/StringRequestContent.java @@ -11,13 +11,11 @@ // ======================================================================== // -package org.eclipse.jetty.client.util; +package org.eclipse.jetty.client; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.eclipse.jetty.client.api.Request; - /** *

A {@link Request.Content} for strings.

*

It is possible to specify, at the constructor, an encoding used to convert diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Synchronizable.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Synchronizable.java deleted file mode 100644 index 482e785b962b..000000000000 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/Synchronizable.java +++ /dev/null @@ -1,40 +0,0 @@ -// -// ======================================================================== -// 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.client; - -/** - *

Implementations of this interface expose a lock object - * via {@link #getLock()} so that callers can synchronize - * externally on that lock:

- *
- * if (iterator instanceof Synchronizable)
- * {
- *     Object element = null;
- *     synchronized (((Synchronizable)iterator).getLock())
- *     {
- *         if (iterator.hasNext())
- *             element = iterator.next();
- *     }
- * }
- * 
- *

In the example above, the calls to {@code hasNext()} and - * {@code next()} are performed "atomically".

- */ -public interface Synchronizable -{ - /** - * @return the lock object to synchronize on - */ - public Object getLock(); -} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/TimeoutCompleteListener.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/TimeoutCompleteListener.java deleted file mode 100644 index 2dc38aad9054..000000000000 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/TimeoutCompleteListener.java +++ /dev/null @@ -1,77 +0,0 @@ -// -// ======================================================================== -// 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.client; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.io.CyclicTimeout; -import org.eclipse.jetty.io.CyclicTimeouts; -import org.eclipse.jetty.util.NanoTime; -import org.eclipse.jetty.util.thread.Scheduler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @deprecated Do not use it, use {@link CyclicTimeouts} instead. - */ -@Deprecated -public class TimeoutCompleteListener extends CyclicTimeout implements Response.CompleteListener -{ - private static final Logger LOG = LoggerFactory.getLogger(TimeoutCompleteListener.class); - - private final AtomicReference requestTimeout = new AtomicReference<>(); - - public TimeoutCompleteListener(Scheduler scheduler) - { - super(scheduler); - } - - @Override - public void onTimeoutExpired() - { - Request request = requestTimeout.getAndSet(null); - if (LOG.isDebugEnabled()) - LOG.debug("Total timeout {} ms elapsed for {} on {}", request.getTimeout(), request, this); - if (request != null) - request.abort(new TimeoutException("Total timeout " + request.getTimeout() + " ms elapsed")); - } - - @Override - public void onComplete(Result result) - { - Request request = requestTimeout.getAndSet(null); - if (request != null) - { - boolean cancelled = cancel(); - if (LOG.isDebugEnabled()) - LOG.debug("Cancelled ({}) timeout for {} on {}", cancelled, request, this); - } - } - - void schedule(HttpRequest request, long timeoutAt) - { - if (requestTimeout.compareAndSet(null, request)) - { - long delay = Math.max(0, NanoTime.until(timeoutAt)); - if (LOG.isDebugEnabled()) - LOG.debug("Scheduling timeout in {} ms for {} on {}", TimeUnit.NANOSECONDS.toMillis(delay), request, this); - schedule(delay, TimeUnit.NANOSECONDS); - } - } -} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/UpgradeProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/UpgradeProtocolHandler.java index 205a15e6d9b7..8fa8b2e34c0e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/UpgradeProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/UpgradeProtocolHandler.java @@ -15,9 +15,10 @@ import java.util.List; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpResponse; +import org.eclipse.jetty.client.internal.ResponseNotifier; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java index 000af78d910c..cb4342525d3f 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java @@ -19,8 +19,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.component.Dumpable; @@ -60,9 +58,9 @@ public class ValidatingConnectionPool extends DuplexConnectionPool private final long timeout; private final Map quarantine; - public ValidatingConnectionPool(HttpDestination destination, int maxConnections, Callback requester, Scheduler scheduler, long timeout) + public ValidatingConnectionPool(Destination destination, int maxConnections, Scheduler scheduler, long timeout) { - super(destination, maxConnections, requester); + super(destination, maxConnections); this.scheduler = scheduler; this.timeout = timeout; this.quarantine = new ConcurrentHashMap<>(maxConnections); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/WWWAuthenticationProtocolHandler.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/WWWAuthenticationProtocolHandler.java index 8edffc8c9ad6..f279abce4e2b 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/WWWAuthenticationProtocolHandler.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/WWWAuthenticationProtocolHandler.java @@ -15,8 +15,6 @@ import java.net.URI; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Destination.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Destination.java deleted file mode 100644 index ae63b6d2b43e..000000000000 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/Destination.java +++ /dev/null @@ -1,61 +0,0 @@ -// -// ======================================================================== -// 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.client.api; - -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.util.FuturePromise; -import org.eclipse.jetty.util.Promise; - -/** - * {@link Destination} represents the triple made of the {@link #getScheme}, the {@link #getHost} - * and the {@link #getPort}. - *

- * {@link Destination} holds a pool of {@link Connection}s, but allows to create unpooled - * connections if the application wants full control over connection management via {@link #newConnection(Promise)}. - *

- * {@link Destination}s may be obtained via {@link HttpClient#resolveDestination(Request)} - */ -public interface Destination -{ - /** - * @return the scheme of this destination, such as "http" or "https" - */ - String getScheme(); - - /** - * @return the host of this destination, such as "127.0.0.1" or "google.com" - */ - String getHost(); - - /** - * @return the port of this destination such as 80 or 443 - */ - int getPort(); - - /** - * Creates asynchronously a new, unpooled, {@link Connection} that will be returned - * at a later time through the given {@link Promise}. - *

- * Use {@link FuturePromise} to wait for the connection: - *

-     * Destination destination = ...;
-     * FuturePromise<Connection> futureConnection = new FuturePromise<>();
-     * destination.newConnection(futureConnection);
-     * Connection connection = futureConnection.get(5, TimeUnit.SECONDS);
-     * 
- * - * @param promise the promise of a new, unpooled, {@link Connection} - */ - void newConnection(Promise promise); -} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpAuthenticationStore.java similarity index 92% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpAuthenticationStore.java index 43f2f11e3af8..57b104a26d95 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpAuthenticationStore.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.net.URI; import java.util.List; @@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.util.AbstractAuthentication; +import org.eclipse.jetty.client.AbstractAuthentication; +import org.eclipse.jetty.client.Authentication; +import org.eclipse.jetty.client.AuthenticationStore; public class HttpAuthenticationStore implements AuthenticationStore { diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpChannel.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpChannel.java index ca899ad82c72..26b8f926e95f 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpChannel.java @@ -11,9 +11,9 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.io.CyclicTimeouts; import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.thread.AutoLock; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConnection.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConnection.java index adb16b46745c..4a969dd4c912 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConnection.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.net.CookieStore; import java.net.HttpCookie; @@ -21,11 +21,15 @@ import java.util.List; import java.util.concurrent.TimeoutException; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Authentication; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpProxy; +import org.eclipse.jetty.client.HttpRequestException; +import org.eclipse.jetty.client.ProxyConfiguration; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContentResponse.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpContentResponse.java similarity index 94% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContentResponse.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpContentResponse.java index e7e459e7e8c7..d7081cbdc823 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContentResponse.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpContentResponse.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; @@ -19,9 +19,9 @@ import java.util.List; import java.util.concurrent.CompletableFuture; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpVersion; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConversation.java similarity index 96% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConversation.java index 654a2df96bd3..d4a24950e0f7 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpConversation.java @@ -11,15 +11,17 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.util.ArrayList; import java.util.Deque; import java.util.List; import java.util.concurrent.ConcurrentLinkedDeque; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.AuthenticationProtocolHandler; +import org.eclipse.jetty.client.RedirectProtocolHandler; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.AttributesMap; import org.eclipse.jetty.util.Promise; import org.slf4j.Logger; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpDestination.java similarity index 93% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpDestination.java index d8edbf2744b4..4d205649b725 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpDestination.java @@ -11,9 +11,8 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; -import java.io.Closeable; import java.io.IOException; import java.nio.channels.AsynchronousCloseException; import java.util.ArrayList; @@ -23,10 +22,14 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeoutException; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.ConnectionPool; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.Origin; +import org.eclipse.jetty.client.ProxyConfiguration; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.ClientConnectionFactory; @@ -50,7 +53,7 @@ import org.slf4j.LoggerFactory; @ManagedObject -public class HttpDestination extends ContainerLifeCycle implements Destination, Closeable, Callback, Dumpable, Sweeper.Sweepable +public class HttpDestination extends ContainerLifeCycle implements Destination, Callback, Dumpable, Sweeper.Sweepable { private static final Logger LOG = LoggerFactory.getLogger(HttpDestination.class); @@ -112,7 +115,7 @@ public void accept(Connection connection) public boolean stale() { - try (AutoLock l = staleLock.lock()) + try (AutoLock ignored = staleLock.lock()) { boolean stale = this.stale; if (!stale) @@ -129,7 +132,7 @@ public boolean sweep() if (LOG.isDebugEnabled()) LOG.debug("Sweep check in progress on {}", this); boolean remove = false; - try (AutoLock l = staleLock.lock()) + try (AutoLock ignored = staleLock.lock()) { boolean stale = exchanges.isEmpty() && connectionPool.isEmpty(); if (!stale) @@ -161,22 +164,19 @@ protected void doStart() throws Exception Sweeper connectionPoolSweeper = client.getBean(Sweeper.class); if (connectionPoolSweeper != null && connectionPool instanceof Sweeper.Sweepable) connectionPoolSweeper.offer((Sweeper.Sweepable)connectionPool); - Sweeper destinationSweeper = getHttpClient().getDestinationSweeper(); - if (destinationSweeper != null) - destinationSweeper.offer(this); } @Override protected void doStop() throws Exception { - Sweeper destinationSweeper = getHttpClient().getDestinationSweeper(); - if (destinationSweeper != null) - destinationSweeper.remove(this); + requestTimeouts.destroy(); + abort(new AsynchronousCloseException()); Sweeper connectionPoolSweeper = client.getBean(Sweeper.class); if (connectionPoolSweeper != null && connectionPool instanceof Sweeper.Sweepable) connectionPoolSweeper.remove((Sweeper.Sweepable)connectionPool); super.doStop(); removeBean(connectionPool); + connectionPool.close(); } protected ConnectionPool newConnectionPool(HttpClient client) @@ -192,21 +192,24 @@ protected Queue newExchangeQueue(HttpClient client) return new BlockingArrayQueue<>(maxCapacity); } - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + private ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { return client.newSslClientConnectionFactory(sslContextFactory, connectionFactory); } + @Override public boolean isSecure() { return HttpClient.isSchemeSecure(getScheme()); } + @Override public HttpClient getHttpClient() { return client; } + @Override public Origin getOrigin() { return origin; @@ -227,6 +230,7 @@ public ResponseNotifier getResponseNotifier() return responseNotifier; } + @Override public ProxyConfiguration.Proxy getProxy() { return proxy; @@ -237,14 +241,12 @@ public ClientConnectionFactory getClientConnectionFactory() return connectionFactory; } - @Override @ManagedAttribute(value = "The destination scheme", readonly = true) public String getScheme() { return getOrigin().getScheme(); } - @Override @ManagedAttribute(value = "The destination host", readonly = true) public String getHost() { @@ -253,7 +255,6 @@ public String getHost() return getOrigin().getAddress().getHost(); } - @Override @ManagedAttribute(value = "The destination port", readonly = true) public int getPort() { @@ -266,11 +267,6 @@ public int getQueuedRequestCount() return exchanges.size(); } - public Origin.Address getConnectAddress() - { - return proxy == null ? getOrigin().getAddress() : proxy.getAddress(); - } - public HttpField getHostField() { return hostField; @@ -294,12 +290,13 @@ public void failed(Throwable x) abort(x); } + @Override public void send(Request request, Response.CompleteListener listener) { ((HttpRequest)request).sendAsync(this, listener); } - protected void send(HttpRequest request, List listeners) + void send(HttpRequest request, List listeners) { send(new HttpExchange(this, request, listeners)); } @@ -456,16 +453,6 @@ public boolean remove(HttpExchange exchange) return exchanges.remove(exchange); } - @Override - public void close() - { - abort(new AsynchronousCloseException()); - if (LOG.isDebugEnabled()) - LOG.debug("Closed {}", this); - connectionPool.close(); - requestTimeouts.destroy(); - } - public void release(Connection connection) { if (LOG.isDebugEnabled()) @@ -547,7 +534,7 @@ public long getIdle() { if (getHttpClient().getDestinationIdleTimeout() <= 0L) return -1; - try (AutoLock l = staleLock.lock()) + try (AutoLock ignored = staleLock.lock()) { return NanoTime.millisSince(activeNanoTime); } @@ -556,7 +543,7 @@ public long getIdle() @ManagedAttribute("Whether this destinations is stale") public boolean isStale() { - try (AutoLock l = staleLock.lock()) + try (AutoLock ignored = staleLock.lock()) { return this.stale; } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpExchange.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpExchange.java index 0106dbb4df8c..87517a60e5a1 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpExchange.java @@ -11,13 +11,13 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.util.List; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.io.CyclicTimeouts; import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.thread.AutoLock; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpReceiver.java similarity index 94% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpReceiver.java index 1782867a6484..0bc75047e443 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpReceiver.java @@ -11,19 +11,18 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; -import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.ContentDecoder; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.ProtocolHandler; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; @@ -131,7 +130,7 @@ protected boolean hasContent() * Subclasses must have set the response status code on the {@link Response} object of the {@link HttpExchange} * prior invoking this method. *

- * This method takes case of notifying {@link org.eclipse.jetty.client.api.Response.BeginListener}s. + * This method takes case of notifying {@link Response.BeginListener}s. * * @param exchange the HTTP exchange */ @@ -176,7 +175,7 @@ protected void responseBegin(HttpExchange exchange) * Subclasses must not have added the header to the {@link Response} object of the {@link HttpExchange} * prior invoking this method. *

- * This method takes case of notifying {@link org.eclipse.jetty.client.api.Response.HeaderListener}s and storing cookies. + * This method takes case of notifying {@link Response.HeaderListener}s and storing cookies. * * @param exchange the HTTP exchange * @param field the response HTTP field @@ -223,27 +222,13 @@ protected void responseHeader(HttpExchange exchange, HttpField field) protected void storeCookie(URI uri, HttpField field) { - try - { - String value = field.getValue(); - if (value != null) - { - Map> header = new HashMap<>(1); - header.put(field.getHeader().asString(), Collections.singletonList(value)); - getHttpDestination().getHttpClient().getCookieManager().put(uri, header); - } - } - catch (IOException x) - { - if (LOG.isDebugEnabled()) - LOG.debug("Unable to store cookies {} from {}", field, uri, x); - } + getHttpDestination().getHttpClient().putCookie(uri, field); } /** * Method to be invoked after all response HTTP headers are available. *

- * This method takes care of notifying {@link org.eclipse.jetty.client.api.Response.HeadersListener}s. + * This method takes care of notifying {@link Response.HeadersListener}s. * * @param exchange the HTTP exchange */ @@ -331,8 +316,8 @@ protected void responseContentAvailable() /** * Method to be invoked when the response is successful. *

- * This method takes care of notifying {@link org.eclipse.jetty.client.api.Response.SuccessListener}s and possibly - * {@link org.eclipse.jetty.client.api.Response.CompleteListener}s (if the exchange is completed). + * This method takes care of notifying {@link Response.SuccessListener}s and possibly + * {@link Response.CompleteListener}s (if the exchange is completed). * * @param exchange the HTTP exchange * @param afterSuccessTask an optional task to invoke afterwards @@ -376,7 +361,7 @@ protected void responseSuccess(HttpExchange exchange, Runnable afterSuccessTask) /** * Method to be invoked when the response is failed. *

- * This method takes care of notifying {@link org.eclipse.jetty.client.api.Response.FailureListener}s. + * This method takes care of notifying {@link Response.FailureListener}s. * * @param failure the response failure */ @@ -589,7 +574,7 @@ protected Content.Chunk transform(Content.Chunk inputChunk) return _chunk; // Retain the input chunk because its ByteBuffer will be referenced by the Inflater. - if (retain && _chunk.hasRemaining()) + if (retain) _chunk.retain(); if (LOG.isDebugEnabled()) LOG.debug("decoding: {}", _chunk); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpRequest.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpRequest.java index 17f41471c1e6..13bca98c8511 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpRequest.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpRequest.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.io.IOException; import java.net.HttpCookie; @@ -35,17 +35,19 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Supplier; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.PathRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.FutureResponseListener; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.Origin; +import org.eclipse.jetty.client.PathRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; @@ -84,11 +86,10 @@ public class HttpRequest implements Request private List requestListeners; private BiFunction pushHandler; private Supplier trailers; - private String upgradeProtocol; private Object tag; private boolean normalized; - protected HttpRequest(HttpClient client, HttpConversation conversation, URI uri) + public HttpRequest(HttpClient client, HttpConversation conversation, URI uri) { this.client = client; this.conversation = conversation; @@ -100,7 +101,7 @@ protected HttpRequest(HttpClient client, HttpConversation conversation, URI uri) extractParams(query); followRedirects(client.isFollowRedirects()); - HttpField acceptEncodingField = client.getAcceptEncodingField(); + HttpField acceptEncodingField = client.getContentDecoderFactories().getAcceptEncodingField(); if (acceptEncodingField != null) headers.put(acceptEncodingField); HttpField userAgentField = client.getUserAgentField(); @@ -627,12 +628,6 @@ public Request trailersSupplier(Supplier trailers) return this; } - public HttpRequest upgradeProtocol(String upgradeProtocol) - { - this.upgradeProtocol = upgradeProtocol; - return this; - } - @Override public Content getBody() { @@ -740,19 +735,15 @@ public ContentResponse send() throws InterruptedException, TimeoutException, Exe @Override public void send(Response.CompleteListener listener) { - sendAsync(client::send, listener); + Destination destination = client.resolveDestination(this); + destination.send(this, listener); } void sendAsync(HttpDestination destination, Response.CompleteListener listener) - { - sendAsync(destination::send, listener); - } - - private void sendAsync(BiConsumer> sender, Response.CompleteListener listener) { if (listener != null) responseListeners.add(listener); - sender.accept(this, responseListeners); + destination.send(this, responseListeners); } void sent() @@ -769,7 +760,7 @@ void sent() * @return The nanoTime at which the timeout expires or {@link Long#MAX_VALUE} if there is no timeout. * @see #timeout(long, TimeUnit) */ - long getTimeoutNanoTime() + public long getTimeoutNanoTime() { return timeoutNanoTime; } @@ -790,11 +781,6 @@ public Supplier getTrailersSupplier() return trailers; } - public String getUpgradeProtocol() - { - return upgradeProtocol; - } - @Override public CompletableFuture abort(Throwable cause) { diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponse.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpResponse.java similarity index 96% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponse.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpResponse.java index ac20e0716491..00904469b540 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpResponse.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpResponse.java @@ -11,15 +11,15 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpVersion; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpSender.java similarity index 99% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpSender.java index d6d4b1f984bd..33cf014bce31 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/HttpSender.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.net.URI; import java.nio.ByteBuffer; @@ -19,8 +19,8 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.io.Content; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/IConnection.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/IConnection.java similarity index 88% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/IConnection.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/IConnection.java index d140039228a0..b72374668e00 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/IConnection.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/IConnection.java @@ -11,9 +11,9 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; -import org.eclipse.jetty.client.api.Connection; +import org.eclipse.jetty.client.Connection; public interface IConnection extends Connection { diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RequestNotifier.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/RequestNotifier.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RequestNotifier.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/RequestNotifier.java index 9f3cae3adf41..827d1be277e5 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/RequestNotifier.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/RequestNotifier.java @@ -11,12 +11,13 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.nio.ByteBuffer; import java.util.List; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.Request; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/ResponseNotifier.java similarity index 94% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/ResponseNotifier.java index c3150521ca92..b817830219b8 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/ResponseNotifier.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; import java.nio.ByteBuffer; import java.util.Iterator; @@ -19,10 +19,10 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.content.ByteBufferContentSource; @@ -308,6 +308,7 @@ private void onDemandCallback() { demultiplexerContentSource.onChunk(chunk); } + chunk.release(); } private void registerFailure(Throwable failure) @@ -368,6 +369,12 @@ public boolean isLast() throw new UnsupportedOperationException(); } + @Override + public boolean canRetain() + { + throw new UnsupportedOperationException(); + } + @Override public void retain() { @@ -383,7 +390,7 @@ public boolean release() @Override public String toString() { - return "ALREADY_READ_CHUNK"; + return "AlreadyReadChunk"; } }; private final int index; @@ -401,9 +408,17 @@ private void onChunk(Content.Chunk chunk) if (LOG.isDebugEnabled()) LOG.debug("Registering content in multiplexed content source #{} that contains {}", index, currentChunk); if (currentChunk == null || currentChunk == ALREADY_READ_CHUNK) - this.chunk = chunk.slice(); + { + if (chunk.hasRemaining()) + chunk = Content.Chunk.asChunk(chunk.getByteBuffer().slice(), chunk.isLast(), chunk); + // Retain the slice because it is stored for later reads. + chunk.retain(); + this.chunk = chunk; + } else if (!currentChunk.isLast()) + { throw new IllegalStateException("Cannot overwrite chunk"); + } onDemandCallback(); } @@ -436,8 +451,8 @@ public Content.Chunk read() } Content.Chunk result = chunk; - if (result != null && !result.isTerminal()) - chunk = ALREADY_READ_CHUNK; + if (result != null) + chunk = result.isLast() ? Content.Chunk.next(result) : ALREADY_READ_CHUNK; if (LOG.isDebugEnabled()) LOG.debug("Content source #{} reading current chunk {}", index, result); return result; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SendFailure.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/SendFailure.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SendFailure.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/SendFailure.java index 12fbd413c489..9d64858e05d0 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/SendFailure.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/SendFailure.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client; +package org.eclipse.jetty.client.internal; public class SendFailure { diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/package-info.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/TunnelRequest.java similarity index 60% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/package-info.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/TunnelRequest.java index 96e946ac0aee..bc4ff1ba0753 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/api/package-info.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/internal/TunnelRequest.java @@ -11,8 +11,17 @@ // ======================================================================== // -/** - * Jetty Client : API Classes - */ -package org.eclipse.jetty.client.api; +package org.eclipse.jetty.client.internal; +import java.net.URI; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.Origin; + +public class TunnelRequest extends HttpRequest +{ + public TunnelRequest(HttpClient client, Origin.Address address) + { + super(client, new HttpConversation(), URI.create("http://" + address.asString())); + } +} diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/package-info.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/package-info.java deleted file mode 100644 index 735185326e04..000000000000 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -// -// ======================================================================== -// 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 -// ======================================================================== -// - -/** - * Jetty Client : Implementation and Core Classes - * - * This package provides APIs, utility classes and an implementation of an asynchronous HTTP client. - *

- * The core class is {@link org.eclipse.jetty.client.HttpClient}, which acts as a central configuration object (for example - * for {@link org.eclipse.jetty.client.HttpClient#setIdleTimeout(long) idle timeouts}, {@link org.eclipse.jetty.client.HttpClient#setMaxConnectionsPerDestination(int) - * max connections per destination}, etc.) and as a factory for {@link org.eclipse.jetty.client.api.Request} objects. - *

- * The HTTP protocol is based on the request/response paradigm, a unit that in this implementation is called - * exchange and is represented by {@link org.eclipse.jetty.client.HttpExchange}. - * An initial request may trigger a sequence of exchanges with one or more servers, called a conversation - * and represented by {@link org.eclipse.jetty.client.HttpConversation}. A typical example of a conversation is a redirect, where - * upon a request for a resource URI, the server replies with a redirect (for example with the 303 status code) - * to another URI. This conversation is made of a first exchange made of the original request and its 303 response, - * and of a second exchange made of the request for the new URI and its 200 response. - *

- * {@link org.eclipse.jetty.client.HttpClient} holds a number of {@link org.eclipse.jetty.client.api.Destination destinations}, which in turn hold a number of - * pooled {@link org.eclipse.jetty.client.api.Connection connections}. - *

- * When a request is sent, its exchange is associated to a connection, either taken from an idle queue or created - * anew, and when both the request and response are completed, the exchange is disassociated from the connection. - * Conversations may span multiple connections on different destinations, and therefore are maintained at the - * {@link org.eclipse.jetty.client.HttpClient} level. - *

- * Applications may decide to send the request and wait for the response in a blocking way, using - * {@link org.eclipse.jetty.client.api.Request#send()}. - * Alternatively, application may ask to be notified of response events asynchronously, using - * {@link org.eclipse.jetty.client.api.Request#send(org.eclipse.jetty.client.api.Response.CompleteListener)}. - */ -package org.eclipse.jetty.client; - diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientConnectionFactory.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientConnectionFactory.java similarity index 93% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientConnectionFactory.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientConnectionFactory.java index fe0bfe115f6d..20849a18c1fc 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientConnectionFactory.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientConnectionFactory.java @@ -11,12 +11,12 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport; import java.util.List; import java.util.Map; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.EndPoint; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/dynamic/HttpClientTransportDynamic.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/dynamic/HttpClientTransportDynamic.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java index eddb3cab0e38..5d8ea47d40bc 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/dynamic/HttpClientTransportDynamic.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportDynamic.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.dynamic; +package org.eclipse.jetty.client.transport; import java.io.IOException; import java.net.SocketAddress; @@ -27,13 +27,14 @@ import org.eclipse.jetty.alpn.client.ALPNClientConnection; import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory; import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.MultiplexConnectionPool; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpRequest; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.ClientConnectionFactory; @@ -76,7 +77,7 @@ * Therefore a destination is identified by a {@link org.eclipse.jetty.client.Origin} and * applications can customize the creation of the origin (for example depending on request protocol * version, or request headers, or request attributes, or even request path) by overriding - * {@link HttpClientTransport#newOrigin(HttpRequest)}.

+ * {@link HttpClientTransport#newOrigin(Request)}.

*/ public class HttpClientTransportDynamic extends AbstractConnectorHttpClientTransport { @@ -117,7 +118,7 @@ public HttpClientTransportDynamic(ClientConnector connector, ClientConnectionFac .collect(Collectors.toList()); Arrays.stream(factoryInfos).forEach(this::addBean); setConnectionPoolFactory(destination -> - new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, 1)); + new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), 1)); } private static ClientConnector findClientConnector(ClientConnectionFactory.Info[] infos) @@ -129,13 +130,13 @@ private static ClientConnector findClientConnector(ClientConnectionFactory.Info[ } @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(Request request) { boolean secure = HttpClient.isSchemeSecure(request.getScheme()); String http1 = "http/1.1"; String http2 = secure ? "h2" : "h2c"; List protocols = List.of(); - if (request.isVersionExplicit()) + if (((HttpRequest)request).isVersionExplicit()) { HttpVersion version = request.getVersion(); String desired = version == HttpVersion.HTTP_2 ? http2 : http1; @@ -175,7 +176,7 @@ public Origin newOrigin(HttpRequest request) } @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { SocketAddress address = origin.getAddress().getSocketAddress(); return new HttpDestination(getHttpClient(), origin, getClientConnector().isIntrinsicallySecure(address)); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportOverHTTP.java similarity index 92% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportOverHTTP.java index 292c78fb5045..e0dc96e32f3e 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpClientTransportOverHTTP.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport; import java.io.IOException; import java.net.SocketAddress; @@ -19,10 +19,11 @@ import java.util.Map; import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.DuplexConnectionPool; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.Origin; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.EndPoint; @@ -56,17 +57,17 @@ public HttpClientTransportOverHTTP(int selectors) public HttpClientTransportOverHTTP(ClientConnector connector) { super(connector); - setConnectionPoolFactory(destination -> new DuplexConnectionPool(destination, getHttpClient().getMaxConnectionsPerDestination(), destination)); + setConnectionPoolFactory(destination -> new DuplexConnectionPool(destination, getHttpClient().getMaxConnectionsPerDestination())); } @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(Request request) { return getHttpClient().createOrigin(request, HTTP11); } @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { SocketAddress address = origin.getAddress().getSocketAddress(); return new HttpDestination(getHttpClient(), origin, getClientConnector().isIntrinsicallySecure(address)); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpChannelOverHTTP.java similarity index 95% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpChannelOverHTTP.java index 9ee061ce2f6e..c5e0402aa7ec 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpChannelOverHTTP.java @@ -11,14 +11,14 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport.internal; import java.util.concurrent.atomic.LongAdder; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpConnectionOverHTTP.java similarity index 90% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpConnectionOverHTTP.java index 112bec38df44..4faa4244c988 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpConnectionOverHTTP.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport.internal; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousCloseException; @@ -24,20 +24,20 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.LongAdder; -import org.eclipse.jetty.client.HttpChannel; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpConversation; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.HttpUpgrader; -import org.eclipse.jetty.client.IConnection; -import org.eclipse.jetty.client.SendFailure; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpConnection; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.IConnection; +import org.eclipse.jetty.client.internal.SendFailure; +import org.eclipse.jetty.client.internal.TunnelRequest; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.AbstractConnection; @@ -204,7 +204,7 @@ public ByteBuffer onUpgradeFrom() void onResponseHeaders(HttpExchange exchange) { HttpRequest request = exchange.getRequest(); - if (request instanceof HttpProxy.TunnelRequest) + if (request instanceof TunnelRequest) { // Restore idle timeout getEndPoint().setIdleTimeout(idleTimeout); @@ -309,7 +309,7 @@ protected void normalizeRequest(HttpRequest request) { super.normalizeRequest(request); - if (request instanceof HttpProxy.TunnelRequest) + if (request instanceof TunnelRequest) { // Override the idle timeout in case it is shorter than the connect timeout. request.idleTimeout(2 * getHttpClient().getConnectTimeout(), TimeUnit.MILLISECONDS); @@ -319,9 +319,10 @@ protected void normalizeRequest(HttpRequest request) HttpUpgrader upgrader = (HttpUpgrader)conversation.getAttribute(HttpUpgrader.class.getName()); if (upgrader == null) { - if (request instanceof HttpUpgrader.Factory) + HttpUpgrader.Factory upgraderFactory = (HttpUpgrader.Factory)request.getAttributes().get(HttpUpgrader.Factory.class.getName()); + if (upgraderFactory != null) { - upgrader = ((HttpUpgrader.Factory)request).newHttpUpgrader(HttpVersion.HTTP_1_1); + upgrader = upgraderFactory.newHttpUpgrader(HttpVersion.HTTP_1_1); conversation.setAttribute(HttpUpgrader.class.getName(), upgrader); upgrader.prepare(request); } diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpReceiverOverHTTP.java similarity index 97% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpReceiverOverHTTP.java index 53b34c481136..3d81b80a0e11 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpReceiverOverHTTP.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport.internal; import java.io.EOFException; import java.nio.ByteBuffer; @@ -19,10 +19,11 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpResponseException; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpResponse; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpMethod; @@ -449,9 +450,10 @@ public boolean content(ByteBuffer buffer) if (chunk != null) throw new IllegalStateException("Content generated with unconsumed content left"); - RetainableByteBuffer networkBuffer = this.networkBuffer; + // Retain the chunk because it is stored for later use. networkBuffer.retain(); - chunk = Content.Chunk.from(buffer, false, networkBuffer); + chunk = Content.Chunk.asChunk(buffer, false, networkBuffer); + if (LOG.isDebugEnabled()) LOG.debug("Setting action to responseContentAvailable on {}", this); if (getAndSetAction(this::responseContentAvailable) != null) diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpSenderOverHTTP.java similarity index 98% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpSenderOverHTTP.java index e75057b80ef1..b7ae70d47cbf 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpSenderOverHTTP.java @@ -11,15 +11,15 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport.internal; import java.nio.ByteBuffer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.HttpRequestException; -import org.eclipse.jetty.client.HttpSender; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.http.HttpGenerator; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.MetaData; diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/ProtocolHttpUpgrader.java similarity index 85% rename from jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java rename to jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/ProtocolHttpUpgrader.java index f28a0a6181a0..4525fd10cc18 100644 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java +++ b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/internal/ProtocolHttpUpgrader.java @@ -11,21 +11,23 @@ // ======================================================================== // -package org.eclipse.jetty.client.http; +package org.eclipse.jetty.client.transport.internal; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpResponseException; import org.eclipse.jetty.client.HttpUpgrader; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpResponse; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; @@ -54,12 +56,12 @@ public ProtocolHttpUpgrader(HttpDestination destination, String protocol) } @Override - public void prepare(HttpRequest request) + public void prepare(Request request) { } @Override - public void upgrade(HttpResponse response, EndPoint endPoint, Callback callback) + public void upgrade(Response response, EndPoint endPoint, Callback callback) { if (response.getHeaders().contains(HttpHeader.UPGRADE, protocol)) { @@ -71,7 +73,7 @@ public void upgrade(HttpResponse response, EndPoint endPoint, Callback callback) Origin origin = destination.getOrigin(); Origin newOrigin = new Origin(origin.getScheme(), origin.getAddress(), origin.getTag(), new Origin.Protocol(List.of(protocol), false)); - HttpDestination newDestination = httpClient.resolveDestination(newOrigin); + Destination newDestination = httpClient.resolveDestination(newOrigin); Map context = new HashMap<>(); context.put(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY, newDestination); diff --git a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/package-info.java b/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/package-info.java deleted file mode 100644 index b080521571b8..000000000000 --- a/jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/util/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -// -// ======================================================================== -// 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 -// ======================================================================== -// - -/** - * Jetty Client : Utility Classes - */ -package org.eclipse.jetty.client.util; - diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java index bd5ec84be6dd..f75ef9f5a858 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java @@ -18,7 +18,7 @@ import java.util.function.Function; import java.util.stream.Stream; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ClientConnectionCloseTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ClientConnectionCloseTest.java index 1163548346c4..bfaf47b7366b 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ClientConnectionCloseTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ClientConnectionCloseTest.java @@ -18,10 +18,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpResponse; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolHelper.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolHelper.java index 1b838f8ff4a6..23659e830210 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolHelper.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolHelper.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.api.Connection; - public class ConnectionPoolHelper { public static Connection acquire(AbstractConnectionPool connectionPool, boolean create) diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolMaxUsageTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolMaxUsageTest.java index 98f2077578f4..4dcedf9889ac 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolMaxUsageTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolMaxUsageTest.java @@ -17,8 +17,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.Content; @@ -76,7 +75,7 @@ public boolean process(Request request, Response response, Callback callback) String host = "localhost"; int port = connector.getLocalPort(); - HttpDestination destination = httpClient.resolveDestination(new Origin("http", host, port, null, HttpClientTransportOverHTTP.HTTP11)); + Destination destination = httpClient.resolveDestination(new Origin("http", host, port, null, HttpClientTransportOverHTTP.HTTP11)); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); int maxUsage = 3; connectionPool.setMaxUsage(maxUsage); @@ -119,7 +118,7 @@ public boolean process(Request request, Response response, Callback callback) String host = "localhost"; int port = connector.getLocalPort(); - HttpDestination destination = httpClient.resolveDestination(new Origin("http", host, port, null, HttpClientTransportOverHTTP.HTTP11)); + Destination destination = httpClient.resolveDestination(new Origin("http", host, port, null, HttpClientTransportOverHTTP.HTTP11)); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); int maxUsage = 3; connectionPool.setMaxUsage(maxUsage); diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolTest.java index 4ad3f0f7ae2f..9d86187b457d 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionPoolTest.java @@ -25,13 +25,8 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; @@ -65,16 +60,16 @@ public class ConnectionPoolTest { private static final Logger LOG = LoggerFactory.getLogger(ConnectionPoolTest.class); - private static final ConnectionPoolFactory DUPLEX = new ConnectionPoolFactory("duplex", destination -> new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination)); - private static final ConnectionPoolFactory MULTIPLEX = new ConnectionPoolFactory("multiplex", destination -> new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, 1)); - private static final ConnectionPoolFactory RANDOM = new ConnectionPoolFactory("random", destination -> new RandomConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, 1)); + private static final ConnectionPoolFactory DUPLEX = new ConnectionPoolFactory("duplex", destination -> new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination())); + private static final ConnectionPoolFactory MULTIPLEX = new ConnectionPoolFactory("multiplex", destination -> new MultiplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), 1)); + private static final ConnectionPoolFactory RANDOM = new ConnectionPoolFactory("random", destination -> new RandomConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), 1)); private static final ConnectionPoolFactory DUPLEX_MAX_DURATION = new ConnectionPoolFactory("duplex-maxDuration", destination -> { - DuplexConnectionPool pool = new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination); + DuplexConnectionPool pool = new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination()); pool.setMaxDuration(10); return pool; }); - private static final ConnectionPoolFactory ROUND_ROBIN = new ConnectionPoolFactory("round-robin", destination -> new RoundRobinConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination)); + private static final ConnectionPoolFactory ROUND_ROBIN = new ConnectionPoolFactory("round-robin", destination -> new RoundRobinConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination())); public static Stream pools() { @@ -487,7 +482,7 @@ public void testMaxDurationConnectionsWithConstrainedPool() throws Exception ConnectionPoolFactory factory = new ConnectionPoolFactory("duplex-maxDuration", destination -> { // Constrain the max pool size to 1. - DuplexConnectionPool pool = new DuplexConnectionPool(destination, maxConnections, destination) + DuplexConnectionPool pool = new DuplexConnectionPool(destination, maxConnections) { @Override protected void onCreated(Connection connection) @@ -541,7 +536,7 @@ public void testMaxDurationConnectionsWithUnconstrainedPool() throws Exception AtomicInteger poolRemoveCounter = new AtomicInteger(); ConnectionPoolFactory factory = new ConnectionPoolFactory("duplex-maxDuration", destination -> { - DuplexConnectionPool pool = new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination) + DuplexConnectionPool pool = new DuplexConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination()) { @Override protected void onCreated(Connection connection) @@ -652,7 +647,7 @@ public void testIdleTimeoutNoRequests(ConnectionPoolFactory factory) throws Exce client.setIdleTimeout(idleTimeout); // Trigger the creation of a destination, that will create the connection pool. - HttpDestination destination = client.resolveDestination(new Origin("http", "localhost", connector.getLocalPort())); + Destination destination = client.resolveDestination(new Origin("http", "localhost", connector.getLocalPort())); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); if (DUPLEX_MAX_DURATION == factory) assertThat(connectionPool.getConnectionCount(), lessThanOrEqualTo(1)); // The connections can expire upon release. diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ContentResponseTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ContentResponseTest.java index f61036cae19e..4cef3c71c90a 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ContentResponseTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ContentResponseTest.java @@ -17,7 +17,6 @@ import java.util.Random; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/DuplexHttpDestinationTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/DuplexHttpDestinationTest.java index 1775b968c0ff..2383e9cabeec 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/DuplexHttpDestinationTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/DuplexHttpDestinationTest.java @@ -20,10 +20,7 @@ import java.util.function.Supplier; import org.awaitility.Awaitility; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.util.NanoTime; @@ -48,7 +45,8 @@ public void testAcquireWithEmptyQueue(Scenario scenario) throws Exception { start(scenario, new EmptyServerHandler()); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false)) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false); + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -60,6 +58,10 @@ public void testAcquireWithEmptyQueue(Scenario scenario) throws Exception } assertNotNull(connection); } + finally + { + destination.stop(); + } } @ParameterizedTest @@ -68,7 +70,8 @@ public void testAcquireWithOneExchangeQueued(Scenario scenario) throws Exception { start(scenario, new EmptyServerHandler()); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false)) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false); + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -84,6 +87,10 @@ public void testAcquireWithOneExchangeQueued(Scenario scenario) throws Exception } assertNotNull(connection); } + finally + { + destination.stop(); + } } @ParameterizedTest @@ -92,7 +99,8 @@ public void testSecondAcquireAfterFirstAcquireWithEmptyQueueReturnsSameConnectio { start(scenario, new EmptyServerHandler()); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false)) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false); + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -111,6 +119,10 @@ public void testSecondAcquireAfterFirstAcquireWithEmptyQueueReturnsSameConnectio assertSame(connection1, connection2); } } + finally + { + destination.stop(); + } } @ParameterizedTest @@ -121,12 +133,12 @@ public void testSecondAcquireConcurrentWithFirstAcquireWithEmptyQueueCreatesTwoC CountDownLatch idleLatch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false) { @Override protected ConnectionPool newConnectionPool(HttpClient client) { - return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this) + return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination()) { @Override protected void onCreated(Connection connection) @@ -144,7 +156,8 @@ protected void onCreated(Connection connection) } }; } - }) + }; + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -175,6 +188,10 @@ protected void onCreated(Connection connection) connection = peekIdleConnection(connectionPool, 5, TimeUnit.SECONDS); assertNotNull(connection); } + finally + { + destination.stop(); + } } @ParameterizedTest @@ -183,7 +200,8 @@ public void testAcquireProcessReleaseAcquireReturnsSameConnection(Scenario scena { start(scenario, new EmptyServerHandler()); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false)) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false); + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -209,6 +227,10 @@ public void testAcquireProcessReleaseAcquireReturnsSameConnection(Scenario scena Connection connection2 = connectionPool.acquire(true); assertSame(connection1, connection2, "After release"); } + finally + { + destination.stop(); + } } @ParameterizedTest @@ -220,7 +242,8 @@ public void testIdleConnectionIdleTimeout(Scenario scenario) throws Exception long idleTimeout = 1000; startClient(scenario, httpClient -> httpClient.setIdleTimeout(idleTimeout)); - try (HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false)) + HttpDestination destination = new HttpDestination(client, new Origin("http", "localhost", connector.getLocalPort()), false); + try { destination.start(); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); @@ -241,6 +264,10 @@ public void testIdleConnectionIdleTimeout(Scenario scenario) throws Exception assertNull(connection1); } } + finally + { + destination.stop(); + } } @ParameterizedTest diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java index 44a4b8facb8b..6bf9c39b11d0 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java @@ -17,9 +17,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.http.HttpScheme; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HostnameVerificationTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HostnameVerificationTest.java index 178be7b8e406..16bbaceed3f3 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HostnameVerificationTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HostnameVerificationTest.java @@ -17,7 +17,7 @@ import java.util.concurrent.ExecutionException; import javax.net.ssl.SSLHandshakeException; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAuthenticationStoreTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAuthenticationStoreTest.java index d038deec0a6a..facccbb1a4f6 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAuthenticationStoreTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAuthenticationStoreTest.java @@ -15,11 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.DigestAuthentication; +import org.eclipse.jetty.client.internal.HttpAuthenticationStore; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAsyncContentTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAsyncContentTest.java index 86dfb170dfaa..0eba74e5c70e 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAsyncContentTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAsyncContentTest.java @@ -63,7 +63,6 @@ protected void service(Request request, org.eclipse.jetty.server.Response respon .scheme(scenario.getScheme()) .onResponseContentAsync((response, chunk, demander) -> { - chunk.release(); contentCount.incrementAndGet(); demanderRef.set(demander); contentLatch.get().countDown(); diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientChunkedContentTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientChunkedContentTest.java index 6feccc767761..08e971c1ed57 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientChunkedContentTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientChunkedContentTest.java @@ -24,11 +24,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -120,7 +115,6 @@ public void testServerContentTerminalClientContentDelay() throws Exception client.newRequest("localhost", server.getLocalPort()) .onResponseContentAsync((response, chunk, demander) -> { - chunk.release(); if (demanderRef.compareAndSet(null, demander)) firstContentLatch.countDown(); else diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCorrelationDataTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCorrelationDataTest.java index b3c643ce386b..49d9c8ed28a7 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCorrelationDataTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCorrelationDataTest.java @@ -15,8 +15,6 @@ import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.server.Response; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCustomProxyTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCustomProxyTest.java index 869530c8e670..9e97442030df 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCustomProxyTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientCustomProxyTest.java @@ -19,8 +19,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.ClientConnectionFactory; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java index 8df09b19bf6a..0f42b3a6da7a 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java @@ -16,12 +16,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.FuturePromise; import org.junit.jupiter.params.ParameterizedTest; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java index c450d30486bb..19c89746bdf5 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java @@ -21,9 +21,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientGZIPTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientGZIPTest.java index 10149b6456ca..3083aaad235f 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientGZIPTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientGZIPTest.java @@ -25,9 +25,6 @@ import java.util.concurrent.TimeUnit; import java.util.zip.GZIPOutputStream; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.InputStreamResponseListener; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ByteBufferPool; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientIdleTimeoutTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientIdleTimeoutTest.java index 258bb7a2fa57..bf7e71a7b4d7 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientIdleTimeoutTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientIdleTimeoutTest.java @@ -18,9 +18,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.IConnection; +import org.eclipse.jetty.client.internal.SendFailure; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.EndPoint; @@ -93,7 +96,7 @@ protected void service(Request request, Response response) client = new HttpClient(new HttpClientTransportOverHTTP(1) { @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { return new HttpDestination(getHttpClient(), origin, false) { diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyProtocolTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyProtocolTest.java index 31a01f40e555..ec3ce503ad91 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyProtocolTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyProtocolTest.java @@ -18,8 +18,7 @@ import java.util.List; import java.util.concurrent.ThreadLocalRandom; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java index a71adc1f45c4..393f079df2cb 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java @@ -19,9 +19,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java index c2a1ad8a06fe..e11d4b3dd2b8 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java @@ -27,11 +27,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.ByteBufferRequestContent; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -451,7 +446,7 @@ public void testHttpRedirector(Scenario scenario) throws Exception start(scenario, new RedirectHandler()); final HttpRedirector redirector = new HttpRedirector(client); - org.eclipse.jetty.client.api.Request request1 = client.newRequest("localhost", connector.getLocalPort()) + org.eclipse.jetty.client.Request request1 = client.newRequest("localhost", connector.getLocalPort()) .scheme(scenario.getScheme()) .path("/303/localhost/302/localhost/done") .timeout(5, TimeUnit.SECONDS) @@ -462,7 +457,7 @@ public void testHttpRedirector(Scenario scenario) throws Exception assertTrue(redirector.isRedirect(response1)); Result result = redirector.redirect(request1, response1); - org.eclipse.jetty.client.api.Request request2 = result.getRequest(); + org.eclipse.jetty.client.Request request2 = result.getRequest(); Response response2 = result.getResponse(); assertEquals(302, response2.getStatus()); @@ -679,10 +674,10 @@ private void testMethodRedirect(final Scenario scenario, final HttpMethod reques start(scenario, new RedirectHandler()); final AtomicInteger passes = new AtomicInteger(); - client.getRequestListeners().add(new org.eclipse.jetty.client.api.Request.Listener.Adapter() + client.getRequestListeners().add(new org.eclipse.jetty.client.Request.Listener.Adapter() { @Override - public void onBegin(org.eclipse.jetty.client.api.Request request) + public void onBegin(org.eclipse.jetty.client.Request request) { int pass = passes.incrementAndGet(); if (pass == 1) diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientSynchronizationTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientSynchronizationTest.java index 5e5f04fa824f..2df5b791e354 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientSynchronizationTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientSynchronizationTest.java @@ -17,9 +17,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; import org.hamcrest.Matchers; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTLSTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTLSTest.java index 330e771e1eb4..28374c541c3d 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTLSTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTLSTest.java @@ -39,8 +39,7 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSocket; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpScheme; @@ -532,7 +531,7 @@ public void testServerRawCloseDetectedByClient() throws Exception client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector)) { @Override - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { SslClientConnectionFactory ssl = (SslClientConnectionFactory)super.newSslClientConnectionFactory(sslContextFactory, connectionFactory); ssl.setRequireCloseMessage(true); @@ -663,7 +662,7 @@ protected int networkFill(ByteBuffer input) throws IOException client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector)) { @Override - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { if (sslContextFactory == null) sslContextFactory = getSslContextFactory(); @@ -692,7 +691,7 @@ protected int networkFill(ByteBuffer input) throws IOException // Create a connection but don't use it. Origin origin = new Origin(HttpScheme.HTTPS.asString(), "localhost", connector.getLocalPort()); - HttpDestination destination = client.resolveDestination(origin); + Destination destination = client.resolveDestination(origin); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); // Trigger the creation of a new connection, but don't use it. ConnectionPoolHelper.tryCreate(connectionPool); @@ -1095,7 +1094,7 @@ protected int networkFill(ByteBuffer input) throws IOException client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector)) { @Override - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { if (sslContextFactory == null) sslContextFactory = getSslContextFactory(); @@ -1125,7 +1124,7 @@ protected int networkFill(ByteBuffer input) throws IOException // Create a connection but don't use it. Origin origin = new Origin(HttpScheme.HTTPS.asString(), "localhost", connector.getLocalPort()); - HttpDestination destination = client.resolveDestination(origin); + Destination destination = client.resolveDestination(origin); DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool(); // Trigger the creation of a new connection, but don't use it. ConnectionPoolHelper.tryCreate(connectionPool); @@ -1157,7 +1156,7 @@ public void testSSLEngineClosedDuringHandshake() throws Exception client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector)) { @Override - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { if (sslContextFactory == null) sslContextFactory = getSslContextFactory(); @@ -1237,7 +1236,7 @@ protected SSLEngineResult unwrap(SSLEngine sslEngine, ByteBuffer input, ByteBuff client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector)) { @Override - protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) + public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory) { if (sslContextFactory == null) sslContextFactory = getSslContextFactory(); diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java index 96dadc8c6732..b1e753885a1f 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java @@ -41,21 +41,11 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.LongConsumer; - -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.StringRequestContent; + +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; @@ -130,7 +120,8 @@ public void testStoppingClosesConnections(Scenario scenario) throws Exception } assertNotNull(connection); - String uri = destination.getScheme() + "://" + destination.getHost() + ":" + destination.getPort(); + Origin origin = destination.getOrigin(); + String uri = origin.getScheme() + "://" + origin.getAddress(); client.getCookieStore().add(URI.create(uri), new HttpCookie("foo", "bar")); client.stop(); @@ -156,9 +147,10 @@ public void testDestinationCount(Scenario scenario) throws Exception assertEquals(1, destinations.size()); Destination destination = destinations.get(0); assertNotNull(destination); - assertEquals(scenario.getScheme(), destination.getScheme()); - assertEquals(host, destination.getHost()); - assertEquals(port, destination.getPort()); + Origin origin = destination.getOrigin(); + assertEquals(scenario.getScheme(), origin.getScheme()); + assertEquals(host, origin.getAddress().getHost()); + assertEquals(port, origin.getAddress().getPort()); } @ParameterizedTest @@ -641,8 +633,7 @@ protected void service(org.eclipse.jetty.server.Request request, org.eclipse.jet AsyncRequestContent body = new AsyncRequestContent(); body.write(false, BufferUtil.allocate(512), Callback.NOOP); - body.write(false, BufferUtil.allocate(512), Callback.NOOP); - body.write(Content.Chunk.from(new IOException("explicitly_thrown_by_test")), Callback.NOOP); + body.write(false, BufferUtil.allocate(512), Callback.from(() -> body.fail(new IOException("explicitly_thrown_by_test")))); CountDownLatch latch = new CountDownLatch(1); client.newRequest("localhost", connector.getLocalPort()) .scheme(scenario.getScheme()) @@ -1420,7 +1411,6 @@ public boolean process(org.eclipse.jetty.server.Request request, org.eclipse.jet @Override public void onContent(Response response, Content.Chunk chunk, Runnable demander) { - chunk.release(); // Do not notify the callback yet. demanderRef.set(demander); contentLatch.countDown(); @@ -1805,7 +1795,7 @@ private void testUnsolicitedBytesFromServer(Scenario scenario, String bytesFromS HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP(clientConnector); transport.setConnectionPoolFactory(destination -> { - ConnectionPool connectionPool = new DuplexConnectionPool(destination, 1, destination); + ConnectionPool connectionPool = new DuplexConnectionPool(destination, 1); connectionPool.preCreateConnections(1); return connectionPool; }); @@ -1816,7 +1806,7 @@ private void testUnsolicitedBytesFromServer(Scenario scenario, String bytesFromS int port = server.getLocalPort(); // Resolve the destination which will pre-create a connection. - HttpDestination destination = client.resolveDestination(new Origin("http", host, port)); + Destination destination = client.resolveDestination(new Origin("http", host, port)); // Accept the connection and send an unsolicited 408. try (Socket socket = server.accept()) diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java index ee55a0ffd745..8459bbfbdd73 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java @@ -28,8 +28,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdownTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdownTest.java index 91b3fcdece6a..55112be5a708 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdownTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdownTest.java @@ -20,10 +20,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.http.HttpChannelOverHTTP; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.Request; @@ -71,8 +71,7 @@ protected void service(Request request, Response response) throws Throwable } else { - if (chunk.hasRemaining()) - chunk.release(); + chunk.release(); if (chunk.isLast()) break; NanoTime.spinWait(TimeUnit.MICROSECONDS.toNanos(1)); diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java index 646f7712e8a7..7a0666fd765e 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java @@ -20,12 +20,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.ByteBufferRequestContent; +import org.eclipse.jetty.client.internal.HttpConnection; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpCookieTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpCookieTest.java index 634c9309ef6c..d067c61fbb4a 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpCookieTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpCookieTest.java @@ -22,8 +22,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.util.HttpCookieStore; @@ -640,7 +638,7 @@ protected void service(Request request, org.eclipse.jetty.server.Response respon }); } - private ContentResponse send(org.eclipse.jetty.client.api.Request request) + private ContentResponse send(org.eclipse.jetty.client.Request request) { try { diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java index e64c60f7e262..4c20dca23eb0 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java @@ -22,9 +22,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.ByteBufferRequestContent; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java index 2f0e0e264a07..c4ee98d96ef2 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java @@ -19,7 +19,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.jetty.client.util.AsyncRequestContent; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseConcurrentAbortTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseConcurrentAbortTest.java index 1b7858832eb8..b988574dd0c6 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseConcurrentAbortTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseConcurrentAbortTest.java @@ -19,8 +19,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Request; import org.junit.jupiter.params.ParameterizedTest; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/InsufficientThreadsDetectionTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/InsufficientThreadsDetectionTest.java index ab6a22bd7f68..2e665d200fa4 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/InsufficientThreadsDetectionTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/InsufficientThreadsDetectionTest.java @@ -13,7 +13,7 @@ package org.eclipse.jetty.client; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.jupiter.api.Test; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/LivelockTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/LivelockTest.java index ac497261254d..60bfb5f695ab 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/LivelockTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/LivelockTest.java @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ManagedSelector; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/NetworkTrafficListenerTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/NetworkTrafficListenerTest.java index ae091e5e3918..4b42b1ed9d68 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/NetworkTrafficListenerTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/NetworkTrafficListenerTest.java @@ -22,10 +22,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.FormRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java index 818ae143acb5..99681c348a23 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java @@ -21,10 +21,8 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.jupiter.api.AfterEach; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/Socks4ProxyTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/Socks4ProxyTest.java index 8d710cf75576..9e6170606fd4 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/Socks4ProxyTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/Socks4ProxyTest.java @@ -28,9 +28,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java index d05e61a21d1f..89c48796767f 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java @@ -23,10 +23,8 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java index 25f6cb1e9597..3a022ff90d5c 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java @@ -16,9 +16,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.FutureResponseListener; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; @@ -37,7 +34,7 @@ public HttpClient newHttpClient(HttpClientTransport transport) { long timeout = 1000; transport.setConnectionPoolFactory(destination -> - new ValidatingConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, destination.getHttpClient().getScheduler(), timeout)); + new ValidatingConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination.getHttpClient().getScheduler(), timeout)); return super.newHttpClient(transport); } diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java index 31d8ac485812..b96716b72eb0 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java @@ -21,14 +21,17 @@ import java.util.concurrent.TimeoutException; import java.util.stream.Stream; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.HttpResponseException; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpCompliance; import org.eclipse.jetty.http.HttpFields; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java index 939002c4e052..f65e8bccf5f3 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java @@ -20,14 +20,15 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ByteBufferRequestContent; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.ByteBufferRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.util.Promise; import org.hamcrest.Matchers; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/NeedWantClientAuthTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/NeedWantClientAuthTest.java index a02b1025952f..b1df0f467a3b 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/NeedWantClientAuthTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/NeedWantClientAuthTest.java @@ -20,10 +20,10 @@ import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.EmptyServerHandler; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ssl.SslHandshakeListener; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/AsyncRequestContentTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/AsyncRequestContentTest.java index 04e13543344c..cd347861c6b6 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/AsyncRequestContentTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/AsyncRequestContentTest.java @@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.util.Callback; import org.junit.jupiter.api.AfterEach; @@ -85,6 +86,7 @@ public void testWriteFlushDemandFlushBlocksUntilRead() throws Exception Content.Chunk chunk = content.read(); assertNotNull(chunk); + chunk.release(); // Flush should return. assertTrue(await(task, 5000)); diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/InputStreamContentTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/InputStreamContentTest.java index 819552d7ebcf..4e3c0192defd 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/InputStreamContentTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/InputStreamContentTest.java @@ -23,10 +23,11 @@ import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.EmptyServerHandler; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartRequestContentTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartRequestContentTest.java index 3bcc08df439b..c43a57d58c26 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartRequestContentTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartRequestContentTest.java @@ -28,7 +28,13 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.client.AbstractHttpClientServerTest; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.PathRequestContent; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/TypedContentProviderTest.java b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/TypedContentProviderTest.java index de5a1f97217d..ccdd4e711dd0 100644 --- a/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/TypedContentProviderTest.java +++ b/jetty-core/jetty-client/src/test/java/org/eclipse/jetty/client/util/TypedContentProviderTest.java @@ -17,8 +17,10 @@ import java.util.List; import org.eclipse.jetty.client.AbstractHttpClientServerTest; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.EmptyServerHandler; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.MimeTypes; diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/module-info.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/module-info.java index f6034926558a..0fa4776d5350 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/module-info.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/module-info.java @@ -18,7 +18,7 @@ requires transitive org.eclipse.jetty.client; exports org.eclipse.jetty.fcgi; - exports org.eclipse.jetty.fcgi.client.http; + exports org.eclipse.jetty.fcgi.client.transport; exports org.eclipse.jetty.fcgi.generator to org.eclipse.jetty.fcgi.server; exports org.eclipse.jetty.fcgi.parser to org.eclipse.jetty.fcgi.server; diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/HttpClientTransportOverFCGI.java similarity index 84% rename from jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java rename to jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/HttpClientTransportOverFCGI.java index 342f44755e76..921fbf24f983 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/HttpClientTransportOverFCGI.java @@ -11,21 +11,22 @@ // ======================================================================== // -package org.eclipse.jetty.fcgi.client.http; +package org.eclipse.jetty.fcgi.client.transport; import java.net.SocketAddress; import java.util.List; import java.util.Map; import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.DuplexConnectionPool; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.fcgi.FCGI; +import org.eclipse.jetty.fcgi.client.transport.internal.HttpConnectionOverFCGI; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.EndPoint; @@ -62,7 +63,7 @@ public HttpClientTransportOverFCGI(ClientConnector connector, String scriptRoot) { HttpClient httpClient = getHttpClient(); int maxConnections = httpClient.getMaxConnectionsPerDestination(); - return new DuplexConnectionPool(destination, maxConnections, destination); + return new DuplexConnectionPool(destination, maxConnections); }); } @@ -73,13 +74,13 @@ public String getScriptRoot() } @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(Request request) { return getHttpClient().createOrigin(request, new Origin.Protocol(List.of("fastcgi/1.1"), false)); } @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { SocketAddress address = origin.getAddress().getSocketAddress(); return new HttpDestination(getHttpClient(), origin, getClientConnector().isIntrinsicallySecure(address)); @@ -91,13 +92,13 @@ public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map promise = (Promise)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY); - org.eclipse.jetty.io.Connection connection = newHttpConnection(endPoint, destination, promise); + org.eclipse.jetty.io.Connection connection = newConnection(endPoint, destination, promise); if (LOG.isDebugEnabled()) LOG.debug("Created {}", connection); return customize(connection, context); } - protected org.eclipse.jetty.io.Connection newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise promise) + protected org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Destination destination, Promise promise) { return new HttpConnectionOverFCGI(endPoint, destination, promise); } diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpChannelOverFCGI.java similarity index 93% rename from jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java rename to jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpChannelOverFCGI.java index e539937b0de4..f45e1b762e33 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpChannelOverFCGI.java @@ -11,20 +11,19 @@ // ======================================================================== // -package org.eclipse.jetty.fcgi.client.http; +package org.eclipse.jetty.fcgi.client.transport.internal; import java.util.concurrent.TimeoutException; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpSender; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.fcgi.generator.Flusher; import org.eclipse.jetty.fcgi.generator.Generator; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.IdleTimeout; @@ -44,7 +43,7 @@ public class HttpChannelOverFCGI extends HttpChannel private int request; private HttpVersion version; - public HttpChannelOverFCGI(final HttpConnectionOverFCGI connection, Flusher flusher, long idleTimeout) + public HttpChannelOverFCGI(HttpConnectionOverFCGI connection, Flusher flusher, long idleTimeout) { super(connection.getHttpDestination()); this.connection = connection; diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpConnectionOverFCGI.java similarity index 91% rename from jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java rename to jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpConnectionOverFCGI.java index 955c59ae740b..d91360e1505a 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpConnectionOverFCGI.java @@ -11,7 +11,7 @@ // ======================================================================== // -package org.eclipse.jetty.fcgi.client.http; +package org.eclipse.jetty.fcgi.client.transport.internal; import java.io.EOFException; import java.nio.ByteBuffer; @@ -22,17 +22,18 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; -import org.eclipse.jetty.client.HttpChannel; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.IConnection; -import org.eclipse.jetty.client.SendFailure; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpConnection; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.IConnection; +import org.eclipse.jetty.client.internal.SendFailure; import org.eclipse.jetty.fcgi.FCGI; import org.eclipse.jetty.fcgi.generator.Flusher; import org.eclipse.jetty.fcgi.parser.ClientParser; @@ -70,10 +71,10 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne private Object attachment; private Runnable action; - public HttpConnectionOverFCGI(EndPoint endPoint, HttpDestination destination, Promise promise) + public HttpConnectionOverFCGI(EndPoint endPoint, Destination destination, Promise promise) { super(endPoint, destination.getHttpClient().getExecutor()); - this.destination = destination; + this.destination = (HttpDestination)destination; this.promise = promise; this.flusher = new Flusher(endPoint); this.delegate = new Delegate(destination); @@ -380,9 +381,9 @@ public String toConnectionString() private class Delegate extends HttpConnection { - private Delegate(HttpDestination destination) + private Delegate(Destination destination) { - super(destination); + super((HttpDestination)destination); } @Override @@ -483,11 +484,13 @@ public boolean onContent(int request, FCGI.StreamType stream, ByteBuffer buffer) HttpChannelOverFCGI channel = HttpConnectionOverFCGI.this.channel; if (channel != null) { - networkBuffer.retain(); - Content.Chunk chunk = Content.Chunk.from(buffer, false, networkBuffer); - if (getAndSetAction(() -> channel.content(chunk)) != null) - throw new IllegalStateException(); - return true; + // No need to call networkBuffer.retain() here, since we know + // that the action will be run before releasing the networkBuffer. + // The receiver of the chunk decides whether to consume/retain it. + Content.Chunk chunk = Content.Chunk.asChunk(buffer, false, networkBuffer); + if (getAndSetAction(() -> channel.content(chunk)) == null) + return true; + throw new IllegalStateException(); } else { diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpReceiverOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpReceiverOverFCGI.java similarity index 92% rename from jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpReceiverOverFCGI.java rename to jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpReceiverOverFCGI.java index 3d1204f4222f..9ab0be7a267f 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpReceiverOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpReceiverOverFCGI.java @@ -11,11 +11,11 @@ // ======================================================================== // -package org.eclipse.jetty.fcgi.client.http; +package org.eclipse.jetty.fcgi.client.transport.internal; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.util.Promise; @@ -98,6 +98,8 @@ void content(Content.Chunk chunk) { if (this.chunk != null) throw new IllegalStateException(); + // Retain the chunk because it is stored for later reads. + chunk.retain(); this.chunk = chunk; responseContentAvailable(); } diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpSenderOverFCGI.java similarity index 94% rename from jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java rename to jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpSenderOverFCGI.java index 0dd0825c4f62..1ebf73917938 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/transport/internal/HttpSenderOverFCGI.java @@ -11,19 +11,20 @@ // ======================================================================== // -package org.eclipse.jetty.fcgi.client.http; +package org.eclipse.jetty.fcgi.client.transport.internal; import java.net.URI; import java.nio.ByteBuffer; import java.util.EnumSet; import java.util.Locale; -import org.eclipse.jetty.client.HttpChannel; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpSender; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.fcgi.FCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.fcgi.generator.ClientGenerator; import org.eclipse.jetty.fcgi.generator.Generator; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/main/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandler.java b/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/main/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandler.java index 93f84bbe76bb..852ec7436446 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/main/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandler.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/main/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandler.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.fcgi.FCGI; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; @@ -279,7 +279,7 @@ protected HttpClient newHttpClient() } @Override - protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) + protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) { proxyToServerRequest.attribute(REMOTE_ADDR_ATTRIBUTE, Request.getRemoteAddr(clientToProxyRequest)); proxyToServerRequest.attribute(REMOTE_PORT_ATTRIBUTE, String.valueOf(Request.getRemotePort(clientToProxyRequest))); @@ -335,7 +335,7 @@ protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclips super.sendProxyToServerRequest(clientToProxyRequest, proxyToServerRequest, proxyToClientResponse, proxyToClientCallback); } - protected void customizeFastCGIHeaders(org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) + protected void customizeFastCGIHeaders(org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) { for (String envName : getFastCGIEnvNames()) { @@ -397,7 +397,7 @@ private ProxyHttpClientTransportOverFCGI(ClientConnector connector, String scrip } @Override - public void customize(org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) + public void customize(org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) { super.customize(proxyToServerRequest, fastCGIHeaders); customizeFastCGIHeaders(proxyToServerRequest, fastCGIHeaders); diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/test/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandlerTest.java b/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/test/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandlerTest.java index adc5357d0bbd..b636c74768d4 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/test/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandlerTest.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-proxy/src/test/java/org/eclipse/jetty/fcgi/proxy/FastCGIProxyHandlerTest.java @@ -19,9 +19,9 @@ import java.util.Random; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.FutureResponseListener; import org.eclipse.jetty.fcgi.FCGI; import org.eclipse.jetty.fcgi.server.ServerFCGIConnectionFactory; import org.eclipse.jetty.http.HttpHeader; @@ -172,10 +172,6 @@ public boolean process(Request request, Response response, Callback callback) { response.abort(x); } - finally - { - chunk.release(); - } }) .path(proxyContext.getContextPath() + path); FutureResponseListener listener = new FutureResponseListener(request, length); diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java index c8f4e6ca3975..885d6924c87f 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java @@ -191,6 +191,8 @@ private void notifyContentAvailable() public void onContent(Content.Chunk chunk) { + // Retain the chunk because it is stored for later reads. + chunk.retain(); _chunk = chunk; } diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java index f1ca41530f04..c6bc575bfc08 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java @@ -371,8 +371,10 @@ public boolean onContent(int request, FCGI.StreamType streamType, ByteBuffer buf LOG.debug("Request {} {} content {} on {}", request, streamType, buffer, stream); if (stream != null) { - networkBuffer.retain(); - stream.onContent(Content.Chunk.from(buffer, false, networkBuffer)); + // No need to call networkBuffer.retain() here. + // The receiver of the chunk decides whether to consume/retain it. + Content.Chunk chunk = Content.Chunk.asChunk(buffer, false, networkBuffer); + stream.onContent(chunk); // Signal that the content is processed asynchronously, to ensure backpressure. return true; } diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java index 82089f5d262e..6c202372cbb6 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java @@ -15,11 +15,11 @@ import java.util.concurrent.atomic.AtomicLong; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; import org.eclipse.jetty.client.LeakTrackingConnectionPool; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ClientConnector; @@ -69,7 +69,7 @@ public void start(Handler handler) throws Exception clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged()); clientConnector.setByteBufferPool(clientBufferPool); HttpClientTransport transport = new HttpClientTransportOverFCGI(clientConnector, ""); - transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination) + transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination()) { @Override protected void leaked(LeakDetector.LeakInfo leakInfo) diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/ExternalFastCGIServerTest.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/ExternalFastCGIServerTest.java index b505545a3903..515ceba395a9 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/ExternalFastCGIServerTest.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/ExternalFastCGIServerTest.java @@ -19,9 +19,9 @@ import java.nio.file.StandardOpenOption; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java index 9d65219527d2..b33600070d30 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java @@ -27,12 +27,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.zip.GZIPOutputStream; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FutureResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.io.Content; @@ -651,7 +651,6 @@ public boolean process(org.eclipse.jetty.server.Request request, org.eclipse.jet .scheme(scheme) .onResponseContentAsync((response, chunk, demander) -> { - chunk.release(); contentCount.incrementAndGet(); demanderRef.set(demander); contentLatch.get().countDown(); diff --git a/jetty-core/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java b/jetty-core/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java index b4029b4a2419..c2b32ce3632d 100644 --- a/jetty-core/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java +++ b/jetty-core/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java @@ -23,10 +23,10 @@ import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpServer; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java index d7074d84a5f0..7a84fc3ca5d4 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java @@ -222,9 +222,9 @@ else if ((_flags & 0x2) == 0x2) if (buffer.hasRemaining()) { - ByteBuffer chunk = buffer; + ByteBuffer decoded = buffer; buffer = null; - if (decodedChunk(chunk)) + if (decodedChunk(decoded)) return; } else if (_inflater.needsInput()) diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPart.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPart.java index 358ac4e329a8..7da150ff0ee2 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPart.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPart.java @@ -631,20 +631,13 @@ public Content.Chunk read() Content.Chunk chunk = part.getContent().read(); if (chunk == null || chunk instanceof Content.Chunk.Error) yield chunk; - if (chunk.isLast()) - { - if (!chunk.hasRemaining()) - { - chunk.release(); - chunk = Content.Chunk.EMPTY; - } - else - { - chunk = Content.Chunk.from(chunk.getByteBuffer(), false, chunk); - } - state = State.MIDDLE; - } - yield chunk; + if (!chunk.isLast()) + yield chunk; + state = State.MIDDLE; + if (chunk.hasRemaining()) + yield Content.Chunk.asChunk(chunk.getByteBuffer(), false, chunk); + chunk.release(); + yield Content.Chunk.EMPTY; } case COMPLETE -> Content.Chunk.EOF; }; @@ -1190,11 +1183,15 @@ private boolean parseContent(Content.Chunk chunk) if (crContent) { crContent = false; - notifyPartContent(Content.Chunk.from(CR.slice(), false)); + Content.Chunk partContentChunk = Content.Chunk.from(CR.slice(), false); + notifyPartContent(partContentChunk); + partContentChunk.release(); } ByteBuffer content = ByteBuffer.wrap(boundaryFinder.getPattern(), 0, partialBoundaryMatch); partialBoundaryMatch = 0; - notifyPartContent(Content.Chunk.from(content, false)); + Content.Chunk partContentChunk = Content.Chunk.from(content, false); + notifyPartContent(partContentChunk); + partContentChunk.release(); return false; } } @@ -1209,7 +1206,7 @@ private boolean parseContent(Content.Chunk chunk) // if we found '\r\n--Boundary' then the '\r' is not content. if (length > 0 && buffer.get(position + length - 1) == '\r') --length; - Content.Chunk content = chunk.slice(position, length, true); + Content.Chunk content = asSlice(chunk, position, length, true); buffer.position(position + boundaryOffset + boundaryFinder.getLength()); notifyPartContent(content); notifyPartEnd(); @@ -1231,7 +1228,7 @@ private boolean parseContent(Content.Chunk chunk) --sliceLimit; } int position = buffer.position(); - Content.Chunk content = chunk.slice(position, sliceLimit - position, false); + Content.Chunk content = asSlice(chunk, position, sliceLimit - position, false); buffer.position(limit); if (content.hasRemaining()) notifyPartContent(content); @@ -1254,13 +1251,22 @@ private boolean parseContent(Content.Chunk chunk) --sliceLimit; } int position = buffer.position(); - Content.Chunk content = chunk.slice(position, sliceLimit - position, false); + Content.Chunk content = asSlice(chunk, position, sliceLimit - position, false); buffer.position(buffer.limit()); if (content.hasRemaining()) notifyPartContent(content); return false; } + private Content.Chunk asSlice(Content.Chunk chunk, int position, int length, boolean last) + { + if (chunk.isLast() && !chunk.hasRemaining()) + return chunk; + if (length == 0) + return last ? Content.Chunk.EOF : Content.Chunk.EMPTY; + return Content.Chunk.asChunk(chunk.getByteBuffer().slice(position, length), last, chunk); + } + private void notifyPartBegin() { try @@ -1383,10 +1389,10 @@ default void onPartHeaders() /** *

Callback method invoked when a part content {@code Chunk} has been parsed.

- *

The {@code Chunk} must be {@link Content.Chunk#release() released} when it - * has been consumed.

+ *

The {@code Chunk} must be {@link Content.Chunk#retain()} retained} if it + * not consumed by this method (for example, stored away for later use).

* - * @param chunk the part content chunk, must be released after use + * @param chunk the part content chunk */ default void onPartContent(Content.Chunk chunk) { diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java index ee210ce1ecae..0f9f0a4eb242 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java @@ -283,6 +283,8 @@ private boolean isFailed() @Override public void onPartContent(Content.Chunk chunk) { + // Retain the chunk because it is stored for later use. + chunk.retain(); partChunks.add(chunk); } diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormData.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormData.java index 6f2c1986843b..e370da194886 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormData.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormData.java @@ -417,7 +417,6 @@ public void onPartContent(Content.Chunk chunk) if (maxFileSize >= 0 && fileSize > maxFileSize) { onFailure(new IllegalStateException("max file size exceeded: %d".formatted(maxFileSize))); - chunk.release(); return; } @@ -438,13 +437,14 @@ public void onPartContent(Content.Chunk chunk) } } write(buffer); - chunk.release(); if (chunk.isLast()) close(); return; } } } + // Retain the chunk because it is stored for later use. + chunk.retain(); partChunks.add(chunk); } diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/Trailers.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/Trailers.java index a8acb78d9560..7ec7f57c7177 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/Trailers.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/Trailers.java @@ -43,16 +43,4 @@ public HttpFields getTrailers() { return trailers; } - - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } } diff --git a/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/MultiPartTest.java b/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/MultiPartTest.java index 8c99d8c00b80..88cc21ba741b 100644 --- a/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/MultiPartTest.java +++ b/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/MultiPartTest.java @@ -658,7 +658,6 @@ public void onPartHeaders() public void onPartContent(Content.Chunk chunk) { events.offer("content last: %b length: %d".formatted(chunk.isLast(), chunk.getByteBuffer().remaining())); - chunk.release(); } @Override @@ -690,6 +689,8 @@ private static class TestPartsListener extends MultiPart.AbstractPartsListener @Override public void onPartContent(Content.Chunk chunk) { + // Retain the chunk because it is stored for later use. + chunk.retain(); partContent.add(chunk); } diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/module-info.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/module-info.java index 6c90a87b1f61..e9b5a6f41538 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/module-info.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/module-info.java @@ -11,7 +11,7 @@ // ======================================================================== // -module org.eclipse.jetty.http2.http.client.transport +module org.eclipse.jetty.http2.client.transport { requires org.eclipse.jetty.alpn.client; requires org.slf4j; diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java index 5ee5b5b29abd..b4b7ae4c0be0 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/ClientConnectionFactoryOverHTTP2.java @@ -18,11 +18,11 @@ import java.util.List; import java.util.Map; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory; import org.eclipse.jetty.http2.client.transport.internal.HTTPSessionListenerPromise; diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java index 0a60027a3303..7bd521271650 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/HttpClientTransportOverHTTP2.java @@ -21,13 +21,14 @@ import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory; import org.eclipse.jetty.client.AbstractHttpClientTransport; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.MultiplexConnectionPool; import org.eclipse.jetty.client.Origin; import org.eclipse.jetty.client.ProxyConfiguration; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.client.HTTP2Client; @@ -55,7 +56,7 @@ public HttpClientTransportOverHTTP2(HTTP2Client client) setConnectionPoolFactory(destination -> { HttpClient httpClient = getHttpClient(); - return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), destination, 1); + return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), 1); }); } @@ -110,14 +111,14 @@ protected void doStop() throws Exception } @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(Request request) { String protocol = HttpScheme.HTTPS.is(request.getScheme()) ? "h2" : "h2c"; return getHttpClient().createOrigin(request, new Origin.Protocol(List.of(protocol), false)); } @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { SocketAddress address = origin.getAddress().getSocketAddress(); return new HttpDestination(getHttpClient(), origin, getHTTP2Client().getClientConnector().isIntrinsicallySecure(address)); @@ -159,7 +160,7 @@ public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) } @Override - protected HttpConnectionOverHTTP2 newHttpConnection(HttpDestination destination, Session session) + protected Connection newConnection(Destination destination, Session session) { - return (HttpConnectionOverHTTP2)HttpClientTransportOverHTTP2.this.newHttpConnection(destination, session); + return HttpClientTransportOverHTTP2.this.newConnection(destination, session); } @Override diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HTTPSessionListenerPromise.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HTTPSessionListenerPromise.java index f38ed870a1c5..0688ab33c699 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HTTPSessionListenerPromise.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HTTPSessionListenerPromise.java @@ -18,9 +18,9 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicMarkableReference; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.Connection; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.frames.GoAwayFrame; import org.eclipse.jetty.http2.frames.SettingsFrame; @@ -52,9 +52,9 @@ public void failed(Throwable failure) failConnectionPromise(failure); } - private HttpDestination destination() + private Destination destination() { - return (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); + return (Destination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); } @SuppressWarnings("unchecked") @@ -72,12 +72,12 @@ public void onSettings(Session session, SettingsFrame frame) private void onServerPreface(Session session) { - HttpConnectionOverHTTP2 connection = newHttpConnection(destination(), session); + HttpConnectionOverHTTP2 connection = (HttpConnectionOverHTTP2)newConnection(destination(), session); if (this.connection.compareAndSet(null, connection, false, true)) httpConnectionPromise().succeeded(connection); } - protected HttpConnectionOverHTTP2 newHttpConnection(HttpDestination destination, Session session) + protected Connection newConnection(Destination destination, Session session) { return new HttpConnectionOverHTTP2(destination, session); } diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpChannelOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpChannelOverHTTP2.java index 3a15b47c5542..55c3c3e380a9 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpChannelOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpChannelOverHTTP2.java @@ -13,12 +13,11 @@ package org.eclipse.jetty.http2.client.transport.internal; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpSender; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.api.Stream; import org.eclipse.jetty.http2.frames.HeadersFrame; @@ -43,9 +42,9 @@ public class HttpChannelOverHTTP2 extends HttpChannel private final HttpReceiverOverHTTP2 receiver; private Stream stream; - public HttpChannelOverHTTP2(HttpDestination destination, HttpConnectionOverHTTP2 connection, Session session) + public HttpChannelOverHTTP2(HttpConnectionOverHTTP2 connection, Session session) { - super(destination); + super(connection.getHttpDestination()); this.connection = connection; this.session = session; this.sender = new HttpSenderOverHTTP2(this); diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpConnectionOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpConnectionOverHTTP2.java index fdbf85f77df1..a96da31d8fe8 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpConnectionOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpConnectionOverHTTP2.java @@ -25,14 +25,15 @@ import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jetty.client.ConnectionPool; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpUpgrader; -import org.eclipse.jetty.client.SendFailure; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpConnection; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpResponse; +import org.eclipse.jetty.client.internal.SendFailure; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.MetaData; @@ -57,9 +58,9 @@ public class HttpConnectionOverHTTP2 extends HttpConnection implements Sweeper.S private final Session session; private boolean recycleHttpChannels = true; - public HttpConnectionOverHTTP2(HttpDestination destination, Session session) + public HttpConnectionOverHTTP2(Destination destination, Session session) { - super(destination); + super((HttpDestination)destination); this.session = session; } @@ -143,9 +144,10 @@ public void upgrade(Map context) protected void normalizeRequest(HttpRequest request) { super.normalizeRequest(request); - if (request instanceof HttpUpgrader.Factory) + HttpUpgrader.Factory upgraderFactory = (HttpUpgrader.Factory)request.getAttributes().get(HttpUpgrader.Factory.class.getName()); + if (upgraderFactory != null) { - HttpUpgrader upgrader = ((HttpUpgrader.Factory)request).newHttpUpgrader(HttpVersion.HTTP_2); + HttpUpgrader upgrader = upgraderFactory.newHttpUpgrader(HttpVersion.HTTP_2); request.getConversation().setAttribute(HttpUpgrader.class.getName(), upgrader); upgrader.prepare(request); } @@ -161,7 +163,7 @@ protected HttpChannelOverHTTP2 acquireHttpChannel() protected HttpChannelOverHTTP2 newHttpChannel() { - return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession()); + return new HttpChannelOverHTTP2(this, getSession()); } protected boolean release(HttpChannelOverHTTP2 channel) diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpReceiverOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpReceiverOverHTTP2.java index a40797f7c0c9..d802c1f15075 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpReceiverOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpReceiverOverHTTP2.java @@ -17,15 +17,15 @@ import java.util.List; import java.util.function.BiFunction; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpConversation; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpUpgrader; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpConversation; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpResponse; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.MetaData; @@ -75,9 +75,11 @@ public Content.Chunk read(boolean fillInterestIfNeeded) } DataFrame frame = data.frame(); boolean last = frame.remaining() == 0 && frame.isEndStream(); - if (last) - responseSuccess(getHttpExchange(), null); - return Content.Chunk.from(frame.getData(), last, data); + if (!last) + return Content.Chunk.asChunk(frame.getData(), last, data); + data.release(); + responseSuccess(getHttpExchange(), null); + return Content.Chunk.EOF; } @Override diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java index bff879c4689f..ce0e731f9ec7 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java @@ -16,9 +16,10 @@ import java.nio.ByteBuffer; import java.util.function.Supplier; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpSender; +import org.eclipse.jetty.client.HttpUpgrader; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.http.HostPortHttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; @@ -55,7 +56,7 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool MetaData.Request metaData; if (isTunnel) { - String upgradeProtocol = request.getUpgradeProtocol(); + String upgradeProtocol = (String)request.getAttributes().get(HttpUpgrader.PROTOCOL_ATTRIBUTE); if (upgradeProtocol == null) { metaData = new MetaData.ConnectRequest((String)null, new HostPortHttpField(request.getPath()), null, request.getHeaders(), null); diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/module-info.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/module-info.java index c033ff1bbe79..bb3593803b1f 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/module-info.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/module-info.java @@ -22,7 +22,7 @@ exports org.eclipse.jetty.http2.api.server; exports org.eclipse.jetty.http2.frames; - exports org.eclipse.jetty.http2.internal to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.http.client.transport, org.eclipse.jetty.http2.server; - exports org.eclipse.jetty.http2.internal.generator to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.http.client.transport, org.eclipse.jetty.http2.server; - exports org.eclipse.jetty.http2.internal.parser to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.http.client.transport, org.eclipse.jetty.http2.server; + exports org.eclipse.jetty.http2.internal to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.client.transport, org.eclipse.jetty.http2.server; + exports org.eclipse.jetty.http2.internal.generator to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.client.transport, org.eclipse.jetty.http2.server; + exports org.eclipse.jetty.http2.internal.parser to org.eclipse.jetty.http2.client, org.eclipse.jetty.http2.client.transport, org.eclipse.jetty.http2.server; } diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/api/Stream.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/api/Stream.java index 1e6f6b65b719..d8003f51fb04 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/api/Stream.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/api/Stream.java @@ -432,18 +432,6 @@ public EOF(int streamId) { super(new DataFrame(streamId, BufferUtil.EMPTY_BUFFER, true)); } - - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } } } } diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Connection.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Connection.java index 87e7d09fe9a6..bf7ee9e5b0eb 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Connection.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Connection.java @@ -404,7 +404,6 @@ private ParserListener(Parser.Listener listener) public void onData(DataFrame frame) { NetworkBuffer networkBuffer = producer.networkBuffer; - networkBuffer.retain(); session.onData(new StreamData(frame, networkBuffer)); } @@ -426,6 +425,12 @@ private StreamData(DataFrame frame, Retainable retainable) this.retainable = retainable; } + @Override + public boolean canRetain() + { + return retainable.canRetain(); + } + @Override public void retain() { @@ -463,6 +468,12 @@ public boolean hasRemaining() return delegate.hasRemaining(); } + @Override + public boolean canRetain() + { + return delegate.canRetain(); + } + @Override public void retain() { diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Session.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Session.java index 019cb232dbb7..9f21c12c23f8 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Session.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Session.java @@ -248,7 +248,7 @@ public void onData(Stream.Data data) { if (getRecvWindow() < 0) { - onSessionFailure(ErrorCode.FLOW_CONTROL_ERROR.code, "session_window_exceeded", toCallback(data)); + onSessionFailure(ErrorCode.FLOW_CONTROL_ERROR.code, "session_window_exceeded", Callback.NOOP); } else { @@ -256,7 +256,7 @@ public void onData(Stream.Data data) { // It's a bad client, it does not deserve to be // treated gently by just resetting the stream. - onSessionFailure(ErrorCode.FLOW_CONTROL_ERROR.code, "stream_window_exceeded", toCallback(data)); + onSessionFailure(ErrorCode.FLOW_CONTROL_ERROR.code, "stream_window_exceeded", Callback.NOOP); } else { @@ -272,36 +272,12 @@ public void onData(Stream.Data data) // otherwise other requests will be stalled. flowControl.onDataConsumed(this, null, flowControlLength); if (isStreamClosed(streamId)) - reset(null, new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), toCallback(data)); + reset(null, new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), Callback.NOOP); else - onSessionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", toCallback(data)); + onSessionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", Callback.NOOP); } } - private Callback toCallback(Stream.Data data) - { - return new Callback() - { - @Override - public void succeeded() - { - data.release(); - } - - @Override - public void failed(Throwable x) - { - data.release(); - } - - @Override - public InvocationType getInvocationType() - { - return InvocationType.NON_BLOCKING; - } - }; - } - private boolean isStreamClosed(int streamId) { return isLocalStream(streamId) ? isLocalStreamClosed(streamId) : isRemoteStreamClosed(streamId); @@ -2305,6 +2281,16 @@ private StreamData(Stream.Data data, HTTP2Stream stream, int flowControlLength) this.data = data; this.stream = stream; this.flowControlLength = flowControlLength; + // Since this class starts its own reference counter + // at 1, we need to retain the delegate Data object, + // so that the releases will be paired. + data.retain(); + } + + @Override + public boolean canRetain() + { + return data.canRetain(); } @Override diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Stream.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Stream.java index ee7b267a9bb9..ba72fa4ee5ee 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Stream.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Stream.java @@ -414,7 +414,6 @@ private void onData(Data data) { if (LOG.isDebugEnabled()) LOG.debug("Data {} for already closed {}", data, this); - data.release(); reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), Callback.NOOP); return; } @@ -424,7 +423,6 @@ private void onData(Data data) // Just drop the frame. if (LOG.isDebugEnabled()) LOG.debug("Data {} for already reset {}", data, this); - data.release(); return; } @@ -436,7 +434,6 @@ private void onData(Data data) { if (LOG.isDebugEnabled()) LOG.debug("Invalid data length {} for {}", data, this); - data.release(); reset(new ResetFrame(streamId, ErrorCode.PROTOCOL_ERROR.code), Callback.NOOP); return; } @@ -448,6 +445,8 @@ private void onData(Data data) private boolean offer(Data data) { + // No need to retain the Data object because it + // has already been retained when it was created. boolean process; try (AutoLock ignored = lock.lock()) { diff --git a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2StreamEndPoint.java b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2StreamEndPoint.java index 54b5163bc076..c7661179bfed 100644 --- a/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2StreamEndPoint.java +++ b/jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2StreamEndPoint.java @@ -177,6 +177,9 @@ public void close(Throwable cause) { if (LOG.isDebugEnabled()) LOG.debug("closing {}, cause: {}", this, cause); + Stream.Data data = this.data.getAndSet(null); + if (data != null) + data.release(); shutdownOutput(); stream.close(); onClose(cause); diff --git a/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java index 0d1b1161e86e..06d4026956f4 100644 --- a/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java @@ -139,6 +139,11 @@ private void onBadMessage(BadMessageException x) @Override public Content.Chunk read() { + // Tunnel requests do not have HTTP content, avoid + // returning chunks meant for a different protocol. + if (tunnelSupport != null) + return null; + while (true) { Content.Chunk chunk; @@ -154,8 +159,10 @@ public Content.Chunk read() if (data == null) return null; + // The data instance should be released after readData() above; + // the chunk is stored below for later use, so should be retained; + // the two actions cancel each other, no need to further retain or release. chunk = createChunk(data); - data.release(); // Some content is read, but the 100 Continue interim // response has not been sent yet, then don't bother @@ -242,11 +249,11 @@ private Content.Chunk createChunk(Stream.Data data) { DataFrame frame = data.frame(); if (frame.isEndStream() && frame.remaining() == 0) + { + data.release(); return Content.Chunk.EOF; - - // We need to retain because we are passing the ByteBuffer to the Chunk. - data.retain(); - return Content.Chunk.from(frame.getData(), frame.isEndStream(), data); + } + return Content.Chunk.asChunk(frame.getData(), frame.isEndStream(), data); } @Override @@ -536,7 +543,7 @@ public TunnelSupport getTunnelSupport() @Override public Throwable consumeAvailable() { - if (HttpMethod.CONNECT.is(_requestMetaData.getMethod())) + if (tunnelSupport != null) return null; return HttpStream.super.consumeAvailable(); } diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/ContentLengthTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/ContentLengthTest.java index b15205fff066..c65199824031 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/ContentLengthTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/ContentLengthTest.java @@ -17,7 +17,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/FlowControlStrategyTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/FlowControlStrategyTest.java index f89e97c98a96..b23bbb3c8506 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/FlowControlStrategyTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/FlowControlStrategyTest.java @@ -571,6 +571,7 @@ public void onDataAvailable(Stream stream) assertTrue(prepareLatch.await(5, TimeUnit.SECONDS)); // Second request will consume half of the remaining the session window. + List dataList2 = new ArrayList<>(); MetaData.Request request2 = newRequest("GET", HttpFields.EMPTY); session.newStream(new HeadersFrame(request2, null, true), new Promise.Adapter<>(), new Stream.Listener() { @@ -581,11 +582,13 @@ public void onDataAvailable(Stream stream) if (!data.frame().isEndStream()) stream.demand(); // Do not release it to stall flow control. + dataList2.add(data); } }); // Third request will consume the whole session window, which is now stalled. // A fourth request will not be able to receive data. + List dataList3 = new ArrayList<>(); MetaData.Request request3 = newRequest("GET", HttpFields.EMPTY); session.newStream(new HeadersFrame(request3, null, true), new Promise.Adapter<>(), new Stream.Listener() { @@ -596,6 +599,7 @@ public void onDataAvailable(Stream stream) if (!data.frame().isEndStream()) stream.demand(); // Do not release it to stall flow control. + dataList3.add(data); } }); @@ -624,6 +628,9 @@ public void onDataAvailable(Stream stream) dataList1.forEach(Stream.Data::release); assertTrue(latch.await(5, TimeUnit.SECONDS)); + + dataList2.forEach(Stream.Data::release); + dataList3.forEach(Stream.Data::release); } @Test @@ -754,6 +761,7 @@ public void onDataAvailable(Stream stream) public void testClientExceedingSessionWindow() throws Exception { // On server, we don't consume the data. + List dataList = new ArrayList<>(); CountDownLatch serverCloseLatch = new CountDownLatch(1); start(new ServerSessionListener() { @@ -769,6 +777,7 @@ public void onDataAvailable(Stream stream) Stream.Data data = stream.readData(); if (!data.frame().isEndStream()) stream.demand(); + dataList.add(data); } }; } @@ -845,12 +854,15 @@ public void succeeded() assertTrue(clientGoAwayLatch.await(5, TimeUnit.SECONDS)); assertTrue(clientCloseLatch.await(5, TimeUnit.SECONDS)); assertTrue(serverCloseLatch.await(5, TimeUnit.SECONDS)); + + dataList.forEach(Stream.Data::release); } @Test public void testClientExceedingStreamWindow() throws Exception { // On server, we don't consume the data. + List dataList = new ArrayList<>(); CountDownLatch serverCloseLatch = new CountDownLatch(1); start(new ServerSessionListener() { @@ -874,6 +886,7 @@ public void onDataAvailable(Stream stream) Stream.Data data = stream.readData(); if (!data.frame().isEndStream()) stream.demand(); + dataList.add(data); } }; } @@ -946,6 +959,8 @@ public void succeeded() assertTrue(clientGoAwayLatch.await(5, TimeUnit.SECONDS)); assertTrue(clientCloseLatch.await(5, TimeUnit.SECONDS)); assertTrue(serverCloseLatch.await(5, TimeUnit.SECONDS)); + + dataList.forEach(Stream.Data::release); } @Test diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/GoAwayTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/GoAwayTest.java index 9fa96751f3c7..df2852641a34 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/GoAwayTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/GoAwayTest.java @@ -15,13 +15,15 @@ import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -387,6 +389,7 @@ public void testServerGoAwayWithStalledStreamServerConsumesDataOfInFlightStream( { int flowControlWindow = 32 * 1024; + List dataList = new ArrayList<>(); AtomicReference serverSessionRef = new AtomicReference<>(); CountDownLatch serverGoAwayLatch = new CountDownLatch(1); CountDownLatch serverCloseLatch = new CountDownLatch(1); @@ -408,7 +411,8 @@ public Stream.Listener onNewStream(Stream stream, HeadersFrame frame) @Override public void onDataAvailable(Stream stream) { - stream.readData(); + Stream.Data data = stream.readData(); + dataList.add(data); // Do not release the Data for this stream. // Only send the response after reading the first DATA frame. if (dataFrames.incrementAndGet() == 1) @@ -513,6 +517,8 @@ public void succeeded(Stream clientStream2) assertFalse(((HTTP2Session)serverSessionRef.get()).getEndPoint().isOpen()); assertFalse(((HTTP2Session)clientSession).getEndPoint().isOpen()); + + dataList.forEach(Stream.Data::release); } @Test diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java index 493a5bb2678e..20ab97593017 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java @@ -34,14 +34,14 @@ import java.util.function.UnaryOperator; import java.util.stream.IntStream; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; +import org.eclipse.jetty.client.InputStreamResponseListener; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -259,7 +259,7 @@ public void onContentSource(Response response, Content.Source contentSource) demander.run(); return; } - if (!chunk.isTerminal()) + if (chunk.hasRemaining()) contentCount.incrementAndGet(); chunk.release(); if (!chunk.isLast()) @@ -328,14 +328,14 @@ public Stream.Listener onNewStream(Stream stream, HeadersFrame frame) httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client) { @Override - protected HttpConnectionOverHTTP2 newHttpConnection(HttpDestination destination, Session session) + protected Connection newConnection(Destination destination, Session session) { return new HttpConnectionOverHTTP2(destination, session) { @Override protected HttpChannelOverHTTP2 newHttpChannel() { - return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession()) + return new HttpChannelOverHTTP2(this, getSession()) { @Override public void setStream(Stream stream) @@ -353,7 +353,7 @@ public void setStream(Stream stream) } @Override - protected void onClose(HttpConnection connection, GoAwayFrame frame) + protected void onClose(Connection connection, GoAwayFrame frame) { super.onClose(connection, frame); lastStream.set(frame.getLastStreamId()); @@ -372,7 +372,7 @@ protected void onClose(HttpConnection connection, GoAwayFrame frame) .send(); assertEquals(HttpStatus.OK_200, response.getStatus()); - org.eclipse.jetty.client.api.Request request = httpClient.newRequest("localhost", connector.getLocalPort()) + org.eclipse.jetty.client.Request request = httpClient.newRequest("localhost", connector.getLocalPort()) .method(HttpMethod.HEAD) .path("/one"); request.send(result -> @@ -522,10 +522,10 @@ public void testClientStopsServerDoesNotCloseClientCloses() throws Exception HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(h2Client) { @Override - protected HttpConnection newHttpConnection(HttpDestination destination, Session session) + protected Connection newConnection(Destination destination, Session session) { sessions.add(session); - return super.newHttpConnection(destination, session); + return super.newConnection(destination, session); } }); QueuedThreadPool clientExecutor = new QueuedThreadPool(); diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MaxConcurrentStreamsTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MaxConcurrentStreamsTest.java index 7524613e4700..3cfdcb19d1bd 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MaxConcurrentStreamsTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MaxConcurrentStreamsTest.java @@ -31,14 +31,15 @@ import java.util.stream.IntStream; import org.eclipse.jetty.client.AbstractConnectionPool; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpResponseException; import org.eclipse.jetty.client.MultiplexConnectionPool; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; @@ -248,7 +249,7 @@ public void onSettings(Session session, SettingsFrame frame) assertEquals(HttpStatus.OK_200, response.getStatus()); assertTrue(latch.await(5, TimeUnit.SECONDS), failures.toString()); assertEquals(2, connections.get()); - HttpDestination destination = (HttpDestination)httpClient.resolveDestination(request); + Destination destination = httpClient.resolveDestination(request); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(2, connectionPool.getConnectionCount()); } @@ -383,7 +384,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon { try { - MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), destination, 1); + MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), 1); pool.preCreateConnections(parallelism * 2).get(); return pool; } diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MultiplexedConnectionPoolTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MultiplexedConnectionPoolTest.java index 812785ae0581..95142a3be91e 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MultiplexedConnectionPoolTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/MultiplexedConnectionPoolTest.java @@ -22,12 +22,12 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.ConnectionPool; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; import org.eclipse.jetty.client.MultiplexConnectionPool; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; @@ -108,7 +108,7 @@ public void testMaxDurationConnectionsWithMultiplexedPoolLifecycle() throws Exce ConnectionPoolFactory factory = new ConnectionPoolFactory("MaxDurationConnectionsWithMultiplexedPoolLifecycle", destination -> { int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination(); - MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, destination, 10) + MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, 10) { @Override protected void onCreated(Connection connection) @@ -209,7 +209,7 @@ public void testStreamIdleTimeout() throws Exception ConnectionPoolFactory factory = new ConnectionPoolFactory("StreamIdleTimeout", destination -> { int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination(); - MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, destination, 10) + MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, 10) { @Override protected void onCreated(Connection connection) @@ -289,7 +289,7 @@ public void testMaxDurationConnectionsWithMultiplexedPool() throws Exception ConnectionPoolFactory factory = new ConnectionPoolFactory("maxDurationConnectionsWithMultiplexedPool", destination -> { int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination(); - MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, destination, MAX_MULTIPLEX) + MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, MAX_MULTIPLEX) { @Override protected void onCreated(Connection connection) @@ -357,7 +357,7 @@ public void testMaxDurationConnectionsWithMultiplexedPoolClosesExpiredConnection ConnectionPoolFactory factory = new ConnectionPoolFactory("duplex-maxDuration", destination -> { int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination(); - MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, destination, MAX_MULTIPLEX) + MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, Pool.StrategyType.FIRST, maxConnections, false, MAX_MULTIPLEX) { @Override protected void onCreated(Connection connection) diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PriorKnowledgeHTTP2OverTLSTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PriorKnowledgeHTTP2OverTLSTest.java index 1e729c885697..04022a84a140 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PriorKnowledgeHTTP2OverTLSTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PriorKnowledgeHTTP2OverTLSTest.java @@ -17,8 +17,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PushedResourcesTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PushedResourcesTest.java index 14efb46735d7..08f51f640dd5 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PushedResourcesTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/PushedResourcesTest.java @@ -20,9 +20,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/RequestTrailersTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/RequestTrailersTest.java index 8e3ae470104e..f87c8438786f 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/RequestTrailersTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/RequestTrailersTest.java @@ -18,10 +18,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; @@ -72,7 +72,7 @@ public void onHeaders(Stream stream, HeadersFrame frame) } }); - HttpRequest request = (HttpRequest)httpClient.newRequest("localhost", connector.getLocalPort()); + Request request = httpClient.newRequest("localhost", connector.getLocalPort()); HttpFields.Mutable trailers = HttpFields.build(); request.trailersSupplier(() -> trailers); if (content != null) @@ -118,7 +118,7 @@ public void onDataAvailable(Stream stream) } }); - HttpRequest request = (HttpRequest)httpClient.newRequest("localhost", connector.getLocalPort()); + Request request = httpClient.newRequest("localhost", connector.getLocalPort()); HttpFields.Mutable trailers = HttpFields.build(); request.trailersSupplier(() -> trailers); AsyncRequestContent content = new AsyncRequestContent(); @@ -169,7 +169,7 @@ public void onDataAvailable(Stream stream) } }); - HttpRequest request = (HttpRequest)httpClient.newRequest("localhost", connector.getLocalPort()); + Request request = httpClient.newRequest("localhost", connector.getLocalPort()); HttpFields.Mutable trailers = HttpFields.build(); request.trailersSupplier(() -> trailers); AsyncRequestContent content = new AsyncRequestContent(); diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java index f9c839ea3bd9..38b22b006efc 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java @@ -709,6 +709,7 @@ public boolean process(Request request, Response response, Callback callback) } }); + List dataList = new ArrayList<>(); AtomicLong received = new AtomicLong(); CountDownLatch latch = new CountDownLatch(1); Session client = newClientSession(new Session.Listener() {}); @@ -721,6 +722,7 @@ public boolean process(Request request, Response response, Callback callback) public void onDataAvailable(Stream stream) { Stream.Data data = stream.readData(); + dataList.add(data); // Do not release to stall the flow control window. if (received.addAndGet(data.frame().getData().remaining()) == windowSize) latch.countDown(); @@ -744,6 +746,8 @@ public void onDataAvailable(Stream stream) HTTP2Session session = (HTTP2Session)sessions.iterator().next(); HTTP2Flusher flusher = session.getBean(HTTP2Flusher.class); assertEquals(0, flusher.getFrameQueueSize()); + + dataList.forEach(Stream.Data::release); } @Test diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/TrailersTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/TrailersTest.java index a60c562c3dd7..b49ef04a0a4e 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/TrailersTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/TrailersTest.java @@ -127,6 +127,7 @@ private void firstRead() // No trailers yet. assertThat(chunk, not(instanceOf(Trailers.class))); + chunk.release(); trailerLatch.countDown(); @@ -143,6 +144,7 @@ private void otherReads() _request.demand(this::otherReads); return; } + chunk.release(); if (chunk instanceof Trailers contentTrailers) { HttpFields trailers = contentTrailers.getTrailers(); diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/module-info.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/module-info.java index b1e3a4a28abd..48b8a1c8e4d9 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/module-info.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/module-info.java @@ -11,7 +11,7 @@ // ======================================================================== // -module org.eclipse.jetty.http3.http.client.transport +module org.eclipse.jetty.http3.client.transport { requires org.slf4j; diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java index 44669a977011..468555b870e4 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/ClientConnectionFactoryOverHTTP3.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.Map; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http3.client.HTTP3Client; import org.eclipse.jetty.http3.client.HTTP3ClientConnectionFactory; import org.eclipse.jetty.http3.client.transport.internal.SessionClientListener; diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java index f79d3b8e9918..ccf4346e4abf 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/HttpClientTransportOverHTTP3.java @@ -21,12 +21,13 @@ import java.util.Objects; import org.eclipse.jetty.client.AbstractHttpClientTransport; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.MultiplexConnectionPool; import org.eclipse.jetty.client.Origin; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http3.HTTP3Configuration; import org.eclipse.jetty.http3.client.HTTP3Client; import org.eclipse.jetty.http3.client.HTTP3ClientConnectionFactory; @@ -34,7 +35,6 @@ import org.eclipse.jetty.http3.client.transport.internal.HttpConnectionOverHTTP3; import org.eclipse.jetty.http3.client.transport.internal.SessionClientListener; import org.eclipse.jetty.io.ClientConnector; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.quic.common.ProtocolSession; import org.eclipse.jetty.quic.common.QuicSession; @@ -51,7 +51,7 @@ public HttpClientTransportOverHTTP3(HTTP3Client client) setConnectionPoolFactory(destination -> { HttpClient httpClient = getHttpClient(); - return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), destination, 1); + return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), 1); }); } @@ -83,13 +83,13 @@ protected void doStart() throws Exception } @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(Request request) { return getHttpClient().createOrigin(request, new Origin.Protocol(List.of("h3"), false)); } @Override - public HttpDestination newHttpDestination(Origin origin) + public Destination newDestination(Origin origin) { SocketAddress address = origin.getAddress().getSocketAddress(); return new HttpDestination(getHttpClient(), origin, getHTTP3Client().getClientConnector().isIntrinsicallySecure(address)); @@ -125,12 +125,12 @@ public ProtocolSession newProtocolSession(QuicSession quicSession, Map context) + public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) { return factory.newConnection(endPoint, context); } - protected HttpConnection newHttpConnection(HttpDestination destination, HTTP3SessionClient session) + protected Connection newConnection(Destination destination, HTTP3SessionClient session) { return new HttpConnectionOverHTTP3(destination, session); } @@ -143,9 +143,9 @@ private TransportSessionClientListener(Map context) } @Override - protected HttpConnectionOverHTTP3 newHttpConnection(HttpDestination destination, HTTP3SessionClient session) + protected Connection newConnection(Destination destination, HTTP3SessionClient session) { - return (HttpConnectionOverHTTP3)HttpClientTransportOverHTTP3.this.newHttpConnection(destination, session); + return HttpClientTransportOverHTTP3.this.newConnection(destination, session); } } } diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpChannelOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpChannelOverHTTP3.java index f45af0765515..377ce0a285b1 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpChannelOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpChannelOverHTTP3.java @@ -13,12 +13,11 @@ package org.eclipse.jetty.http3.client.transport.internal; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpSender; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.http3.api.Stream; import org.eclipse.jetty.http3.client.internal.HTTP3SessionClient; import org.eclipse.jetty.http3.internal.HTTP3ErrorCode; @@ -31,9 +30,9 @@ public class HttpChannelOverHTTP3 extends HttpChannel private final HttpReceiverOverHTTP3 receiver; private Stream stream; - public HttpChannelOverHTTP3(HttpDestination destination, HttpConnectionOverHTTP3 connection, HTTP3SessionClient session) + public HttpChannelOverHTTP3(HttpConnectionOverHTTP3 connection, HTTP3SessionClient session) { - super(destination); + super(connection.getHttpDestination()); this.connection = connection; this.session = session; sender = new HttpSenderOverHTTP3(this); diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpConnectionOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpConnectionOverHTTP3.java index 489bd4e9106b..a92f65513fae 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpConnectionOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpConnectionOverHTTP3.java @@ -20,12 +20,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.jetty.client.ConnectionPool; -import org.eclipse.jetty.client.HttpChannel; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.SendFailure; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.internal.HttpChannel; +import org.eclipse.jetty.client.internal.HttpConnection; +import org.eclipse.jetty.client.internal.HttpDestination; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.SendFailure; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http3.client.internal.HTTP3SessionClient; import org.slf4j.Logger; @@ -39,9 +40,9 @@ public class HttpConnectionOverHTTP3 extends HttpConnection implements Connectio private final AtomicBoolean closed = new AtomicBoolean(); private final HTTP3SessionClient session; - public HttpConnectionOverHTTP3(HttpDestination destination, HTTP3SessionClient session) + public HttpConnectionOverHTTP3(Destination destination, HTTP3SessionClient session) { - super(destination); + super((HttpDestination)destination); this.session = session; } @@ -86,7 +87,7 @@ public SendFailure send(HttpExchange exchange) protected HttpChannelOverHTTP3 newHttpChannel() { - return new HttpChannelOverHTTP3(getHttpDestination(), this, getSession()); + return new HttpChannelOverHTTP3(this, getSession()); } public void release(HttpChannelOverHTTP3 channel) diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpReceiverOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpReceiverOverHTTP3.java index 729c31632736..f5a9b5145ae2 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpReceiverOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpReceiverOverHTTP3.java @@ -15,9 +15,9 @@ import java.nio.ByteBuffer; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpReceiver; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpReceiver; +import org.eclipse.jetty.client.internal.HttpResponse; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.MetaData; @@ -60,9 +60,11 @@ public Content.Chunk read(boolean fillInterestIfNeeded) } ByteBuffer byteBuffer = data.getByteBuffer(); boolean last = !byteBuffer.hasRemaining() && data.isLast(); - if (last) - responseSuccess(getHttpExchange(), null); - return Content.Chunk.from(byteBuffer, last, data); + if (!last) + return Content.Chunk.asChunk(byteBuffer, last, data); + data.release(); + responseSuccess(getHttpExchange(), null); + return Content.Chunk.EOF; } @Override diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java index 7e7566334a17..be500f50c388 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java @@ -17,9 +17,10 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpSender; +import org.eclipse.jetty.client.HttpUpgrader; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.internal.HttpRequest; +import org.eclipse.jetty.client.internal.HttpSender; import org.eclipse.jetty.http.HostPortHttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; @@ -55,7 +56,7 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool MetaData.Request metaData; if (isTunnel) { - String upgradeProtocol = request.getUpgradeProtocol(); + String upgradeProtocol = (String)request.getAttributes().get(HttpUpgrader.PROTOCOL_ATTRIBUTE); if (upgradeProtocol == null) { metaData = new MetaData.ConnectRequest((String)null, new HostPortHttpField(request.getPath()), null, request.getHeaders(), null); diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/SessionClientListener.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/SessionClientListener.java index c42bda148dea..0fb5f1cf620d 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/SessionClientListener.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/SessionClientListener.java @@ -18,9 +18,10 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicMarkableReference; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.Connection; +import org.eclipse.jetty.client.internal.HttpDestination; import org.eclipse.jetty.http3.api.Session; import org.eclipse.jetty.http3.client.internal.HTTP3SessionClient; import org.eclipse.jetty.http3.frames.SettingsFrame; @@ -47,7 +48,7 @@ public void onConnect(Session.Client session, Throwable failure) public void onSettings(Session session, SettingsFrame frame) { HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); - HttpConnectionOverHTTP3 connection = newHttpConnection(destination, (HTTP3SessionClient)session); + HttpConnectionOverHTTP3 connection = (HttpConnectionOverHTTP3)newConnection(destination, (HTTP3SessionClient)session); if (this.connection.compareAndSet(null, connection, false, true)) httpConnectionPromise().succeeded(connection); } @@ -81,7 +82,7 @@ public void onFailure(Session session, long error, String reason, Throwable fail connection.close(failure); } - protected HttpConnectionOverHTTP3 newHttpConnection(HttpDestination destination, HTTP3SessionClient session) + protected Connection newConnection(Destination destination, HTTP3SessionClient session) { return new HttpConnectionOverHTTP3(destination, session); } diff --git a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/module-info.java b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/module-info.java index c773a7e48010..42f0617c5103 100644 --- a/jetty-core/jetty-http3/jetty-http3-client/src/main/java/module-info.java +++ b/jetty-core/jetty-http3/jetty-http3-client/src/main/java/module-info.java @@ -25,5 +25,5 @@ exports org.eclipse.jetty.http3.client; exports org.eclipse.jetty.http3.client.internal to - org.eclipse.jetty.http3.http.client.transport; + org.eclipse.jetty.http3.client.transport; } diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/module-info.java b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/module-info.java index b98b7ffbda04..aa0a206cae24 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/module-info.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/module-info.java @@ -28,7 +28,7 @@ exports org.eclipse.jetty.http3.internal to org.eclipse.jetty.http3.client, org.eclipse.jetty.http3.server, - org.eclipse.jetty.http3.http.client.transport; + org.eclipse.jetty.http3.client.transport; exports org.eclipse.jetty.http3.internal.generator to org.eclipse.jetty.http3.client, org.eclipse.jetty.http3.server; diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/api/Stream.java b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/api/Stream.java index cca2e8e43a4b..8b194ff217e6 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/api/Stream.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/api/Stream.java @@ -411,18 +411,6 @@ private EOFData() { super(new DataFrame(BufferUtil.EMPTY_BUFFER, true)); } - - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } } } } diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3Stream.java b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3Stream.java index 768af9ccae8f..4e1dfc71da94 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3Stream.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3Stream.java @@ -334,6 +334,8 @@ private void onDataAvailable() public void onData(Data data) { + // Retain the data because it is stored for later reads. + data.retain(); if (!dataRef.compareAndSet(null, data)) throw new IllegalStateException(); diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3StreamConnection.java b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3StreamConnection.java index b9ace8f2d452..21766cc042a7 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3StreamConnection.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/main/java/org/eclipse/jetty/http3/internal/HTTP3StreamConnection.java @@ -350,6 +350,12 @@ public StreamData(DataFrame frame, RetainableByteBuffer retainable) this.retainable = retainable; } + @Override + public boolean canRetain() + { + return retainable.canRetain(); + } + @Override public void retain() { @@ -432,7 +438,8 @@ public void onData(long streamId, DataFrame frame) } else { - networkBuffer.retain(); + // No need to call networkBuffer.retain() here, since we know + // that the action will be run before releasing the networkBuffer. data = new StreamData(frame, networkBuffer); } diff --git a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java index 894287323986..1b4ebf7a92ef 100644 --- a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java @@ -147,8 +147,10 @@ public Content.Chunk read() if (data == null) return null; + // The data instance should be released after readData() above; + // the chunk is stored below for later use, so should be retained; + // the two actions cancel each other, no need to further retain or release. chunk = createChunk(data); - data.release(); // Some content is read, but the 100 Continue interim // response has not been sent yet, then don't bother @@ -204,8 +206,10 @@ public Runnable onDataAvailable() return null; } + // The data instance should be released after readData() above; + // the chunk is stored below for later use, so should be retained; + // the two actions cancel each other, no need to further retain or release. Content.Chunk chunk = createChunk(data); - data.release(); try (AutoLock ignored = lock.lock()) { @@ -234,11 +238,11 @@ public Runnable onTrailer(HeadersFrame frame) private Content.Chunk createChunk(Stream.Data data) { if (data == Stream.Data.EOF) + { + data.release(); return Content.Chunk.EOF; - - // As we are passing the ByteBuffer to the Chunk we need to retain. - data.retain(); - return Content.Chunk.from(data.getByteBuffer(), data.isLast(), data); + } + return Content.Chunk.asChunk(data.getByteBuffer(), data.isLast(), data); } @Override diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/AbstractClientServerTest.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/AbstractClientServerTest.java index 02e06941211c..6ea54ac8194d 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/AbstractClientServerTest.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/AbstractClientServerTest.java @@ -19,7 +19,7 @@ import javax.management.MBeanServer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpURI; diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/DataDemandTest.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/DataDemandTest.java index a62f8825cd3f..162b934e7207 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/DataDemandTest.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/DataDemandTest.java @@ -80,10 +80,16 @@ public void onDataAvailable(Stream.Server stream) { // When resumed, demand all content until the last. Stream.Data data = stream.readData(); - if (data != null && data.isLast()) - serverDataLatch.countDown(); - else - stream.demand(); + if (data != null) + { + data.release(); + if (data.isLast()) + { + serverDataLatch.countDown(); + return; + } + } + stream.demand(); } } }; @@ -129,7 +135,14 @@ public void onDataAvailable(Stream.Server stream) if (serverStreamRef.compareAndSet(null, stream)) { // Read only one chunk of data. - await().atMost(1, TimeUnit.SECONDS).until(() -> stream.readData() != null); + await().atMost(1, TimeUnit.SECONDS).until(() -> + { + Stream.Data data = stream.readData(); + if (data == null) + return false; + data.release(); + return true; + }); serverStreamLatch.countDown(); // Don't demand, just exit. } @@ -137,10 +150,16 @@ public void onDataAvailable(Stream.Server stream) { // When resumed, demand all content until the last. Stream.Data data = stream.readData(); - if (data != null && data.isLast()) - serverDataLatch.countDown(); - else - stream.demand(); + if (data != null) + { + data.release(); + if (data.isLast()) + { + serverDataLatch.countDown(); + return; + } + } + stream.demand(); } } }; @@ -198,6 +217,10 @@ public void onDataAvailable(Stream.Server stream) serverStreamLatch.countDown(); break; } + else + { + data.release(); + } } // Do not demand after reading null data. } @@ -205,10 +228,16 @@ public void onDataAvailable(Stream.Server stream) { // When resumed, demand all content until the last. Stream.Data data = stream.readData(); - if (data != null && data.isLast()) - serverDataLatch.countDown(); - else - stream.demand(); + if (data != null) + { + data.release(); + if (data.isLast()) + { + serverDataLatch.countDown(); + return; + } + } + stream.demand(); } } }; @@ -293,6 +322,7 @@ public void onDataAvailable(Stream.Server stream) } if (dataRead.addAndGet(data.getByteBuffer().remaining()) == dataLength) serverDataLatch.countDown(); + data.release(); if (!data.isLast()) stream.demand(); } @@ -378,6 +408,7 @@ public void onDataAvailable(Stream.Server stream) ByteBuffer buffer = ByteBuffer.wrap(bytesReceived); datas.forEach(d -> buffer.put(d.getByteBuffer())); assertArrayEquals(bytesSent, bytesReceived); + datas.forEach(Stream.Data::release); } @Test @@ -402,10 +433,16 @@ public void onDataAvailable(Stream.Server stream) { onDataAvailableCalls.incrementAndGet(); Stream.Data data = stream.readData(); - if (data != null && data.isLast()) - serverDataLatch.countDown(); - else - stream.demand(); + if (data != null) + { + data.release(); + if (data.isLast()) + { + serverDataLatch.countDown(); + return; + } + } + stream.demand(); } }; } @@ -531,6 +568,7 @@ public void onDataAvailable(Stream.Server stream) if (data == null) continue; firstData = true; + data.release(); break; } @@ -614,9 +652,8 @@ public void onDataAvailable(Stream.Client stream) { String content = StandardCharsets.UTF_8.decode(data.getByteBuffer()).toString(); assertEquals("hello", content); - data.release(); assertTrue(data.isLast()); - + data.release(); // Demand one more time, we should get an EOF. stream.demand(); } @@ -625,6 +662,7 @@ public void onDataAvailable(Stream.Client stream) assertNotNull(data); assertTrue(data.isLast()); assertEquals(0, data.getByteBuffer().remaining()); + data.release(); latch.countDown(); } } diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java index 3ff941914d84..a18b73119672 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java @@ -18,8 +18,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpURI; diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/HttpClientTransportOverHTTP3Test.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/HttpClientTransportOverHTTP3Test.java index 6fab93a2ecc0..d407cfd49140 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/HttpClientTransportOverHTTP3Test.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/HttpClientTransportOverHTTP3Test.java @@ -19,8 +19,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.Content; @@ -119,7 +119,7 @@ public void onContentSource(Response response, Content.Source contentSource) demander.run(); return; } - if (!chunk.isTerminal()) + if (chunk.hasRemaining()) contentCount.incrementAndGet(); chunk.release(); if (!chunk.isLast()) diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java index a586f66babe7..d074798c6514 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java @@ -436,11 +436,50 @@ public interface Chunk extends Retainable /** *

An empty, non-last, chunk.

*/ - Chunk EMPTY = ByteBufferChunk.EMPTY; + Chunk EMPTY = new Chunk() + { + @Override + public ByteBuffer getByteBuffer() + { + return BufferUtil.EMPTY_BUFFER; + } + + @Override + public boolean isLast() + { + return false; + } + + @Override + public String toString() + { + return "EMPTY"; + } + }; + /** *

An empty, last, chunk.

*/ - Content.Chunk EOF = ByteBufferChunk.EOF; + Content.Chunk EOF = new Chunk() + { + @Override + public ByteBuffer getByteBuffer() + { + return BufferUtil.EMPTY_BUFFER; + } + + @Override + public boolean isLast() + { + return true; + } + + @Override + public String toString() + { + return "EOF"; + } + }; /** *

Creates a Chunk with the given ByteBuffer.

@@ -492,17 +531,22 @@ static Chunk from(ByteBuffer byteBuffer, boolean last, Consumer rele } /** - *

Creates a last/non-last Chunk with the given ByteBuffer, linked to the given Retainable.

- *

The {@link #retain()} and {@link #release()} methods of this Chunk will delegate to the - * given Retainable.

+ *

Returns the given {@code ByteBuffer} and {@code last} arguments + * as a {@code Chunk}, linked to the given {@link Retainable}.

+ *

The {@link #retain()} and {@link #release()} methods of this + * {@code Chunk} will delegate to the given {@code Retainable}.

* * @param byteBuffer the ByteBuffer with the bytes of this Chunk * @param last whether the Chunk is the last one * @param retainable the Retainable this Chunk links to * @return a new Chunk + * @throws IllegalArgumentException if the {@code Retainable} + * {@link Retainable#canRetain() cannot be retained} */ - static Chunk from(ByteBuffer byteBuffer, boolean last, Retainable retainable) + static Chunk asChunk(ByteBuffer byteBuffer, boolean last, Retainable retainable) { + if (!retainable.canRetain()) + throw new IllegalArgumentException("Cannot create chunk from non-retainable " + retainable); if (byteBuffer.hasRemaining()) return new ByteBufferChunk.WithRetainable(byteBuffer, last, Objects.requireNonNull(retainable)); retainable.release(); @@ -521,7 +565,7 @@ static Error from(Throwable failure) } /** - *

Returns the chunk that follows a chunk that has been consumed.

+ *

Returns the chunk that follows the given chunk.

* * * @@ -569,63 +613,6 @@ static Chunk next(Chunk chunk) */ boolean isLast(); - /** - *

Returns a new {@code Chunk} whose {@code ByteBuffer} is a slice of the - * {@code ByteBuffer} of the source {@code Chunk} unless the source - * {@link #hasRemaining() has no remaining byte} in which case:

- *
    - *
  • {@code this} is returned if it is an instance of {@link Error}
  • - *
  • {@link #EOF} is returned if {@link #isLast()} is {@code true}
  • - *
  • {@link #EMPTY} is returned if {@link #isLast()} is {@code false}
  • - *
- *

If the source has remaining bytes, the returned {@code Chunk} retains - * the source {@code Chunk} and it is linked to it via - * {@link #from(ByteBuffer, boolean, Retainable)}.

- * - * @return a new {@code Chunk} retained from the source {@code Chunk} with a slice - * of the source {@code Chunk}'s {@code ByteBuffer} - */ - default Chunk slice() - { - if (isTerminal()) - return this; - if (!hasRemaining()) - return EMPTY; - retain(); - return from(getByteBuffer().slice(), isLast(), this); - } - - /** - *

Returns a new {@code Chunk} whose {@code ByteBuffer} is a slice of the - * {@code ByteBuffer} of this {@code Chunk}.

- *

The returned {@code Chunk} is:

- *
    - *
  • {@code this}, if this {@code Chunk} is {@link #isTerminal() terminal}
  • - *
  • {@link #EMPTY}, if {@code length == 0 && !last}
  • - *
  • {@link #EOF}, if {@code length == 0 && last}
  • - *
  • a new {@code Chunk} whose {@code ByteBuffer} is a slice of the - * {@code ByteBuffer} of this {@code Chunk}, from the given {@code position} - * and for the given {@code length} bytes.
  • - *
- *

The returned {@code Chunk} retains the source {@code Chunk} and it is linked - * to it via {@link #from(ByteBuffer, boolean, Retainable)}.

- * - * @param position the position at which the slice begins - * @param length the length of the slice - * @param last whether the new Chunk is last - * @return a new {@code Chunk} retained from the source {@code Chunk} with a slice - * of the source {@code Chunk}'s {@code ByteBuffer} - */ - default Chunk slice(int position, int length, boolean last) - { - if (isTerminal()) - return this; - if (length == 0) - return last ? EOF : EMPTY; - retain(); - return from(getByteBuffer().slice(position, length), last, this); - } - /** * @return the number of bytes remaining in this Chunk */ @@ -668,31 +655,14 @@ default int get(byte[] bytes, int offset, int length) */ default int skip(int length) { + if (length == 0) + return 0; ByteBuffer byteBuffer = getByteBuffer(); length = Math.min(byteBuffer.remaining(), length); byteBuffer.position(byteBuffer.position() + length); return length; } - /** - *

Returns whether this Chunk is a terminal chunk.

- *

A terminal chunk is a Chunk that {@link #isLast()} is true - * and has no remaining bytes.

- *

Terminal chunks cannot be lifecycled using the - * {@link Retainable} contract like other chunks: they always throw - * {@link UnsupportedOperationException} on {@link #retain()} and - * always return {@code true} on {@link #release()}. As such, they - * cannot contain a recyclable buffer and calling their - * {@link #release()} method isn't necessary, although harmless. - *

- * - * @return whether this Chunk is a terminal chunk - */ - default boolean isTerminal() - { - return isLast() && !hasRemaining(); - } - /** *

A chunk that wraps a failure.

*

Error Chunks are always last and have no bytes to read, @@ -726,18 +696,6 @@ public boolean isLast() return true; } - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } - @Override public String toString() { diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Retainable.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Retainable.java index a2115be66404..d8e7dcabff5c 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Retainable.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Retainable.java @@ -27,19 +27,40 @@ public interface Retainable { /** - *

Retains this resource, incrementing the reference count.

+ *

Returns whether this resource is referenced counted by calls to {@link #retain()} + * and {@link #release()}.

+ *

Implementations may decide that special resources are not not referenced counted (for example, + * {@code static} constants) so calling {@link #retain()} is a no-operation, and + * calling {@link #release()} on those special resources is a no-operation that always returns true.

+ * + * @return true if calls to {@link #retain()} are reference counted. + */ + default boolean canRetain() + { + return false; + } + + /** + *

Retains this resource, potentially incrementing a reference count if there are resources that will be released.

*/ - void retain(); + default void retain() + { + } /** - *

Releases this resource, decrementing the reference count.

- *

This method returns {@code true} when the reference count goes to zero, - * {@code false} otherwise.

+ *

Releases this resource, potentially decrementing a reference count (if any).

* - * @return whether the invocation of this method decremented the reference count to zero + * @return {@code true} when the reference count goes to zero or if there was no reference count, + * {@code false} otherwise. */ - boolean release(); + default boolean release() + { + return true; + } + /** + * A wrapper of {@link Retainable} instances. + */ class Wrapper implements Retainable { private final Retainable wrapped; @@ -54,6 +75,12 @@ public Retainable getWrapped() return wrapped; } + @Override + public boolean canRetain() + { + return getWrapped().canRetain(); + } + @Override public void retain() { @@ -108,6 +135,12 @@ protected void acquire() throw new IllegalStateException("acquired while in use " + this); } + @Override + public boolean canRetain() + { + return true; + } + @Override public void retain() { diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/AsyncContent.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/AsyncContent.java index 932802c8df2e..e874f8e960ed 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/AsyncContent.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/AsyncContent.java @@ -23,6 +23,9 @@ import java.util.Queue; import org.eclipse.jetty.io.Content; +import org.eclipse.jetty.io.Retainable; +import org.eclipse.jetty.io.internal.ByteBufferChunk; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.util.thread.SerializedInvoker; @@ -37,10 +40,18 @@ public class AsyncContent implements Content.Sink, Content.Source, Closeable { private static final int UNDETERMINED_LENGTH = -2; + private static final AsyncChunk ASYNC_EOF = new AsyncChunk(true, BufferUtil.EMPTY_BUFFER, Callback.NOOP) + { + @Override + public String toString() + { + return "ASYNC_EOF"; + } + }; private final AutoLock.WithCondition lock = new AutoLock.WithCondition(); private final SerializedInvoker invoker = new SerializedInvoker(); - private final Queue chunks = new ArrayDeque<>(); + private final Queue chunks = new ArrayDeque<>(); private Content.Chunk.Error errorChunk; private boolean readClosed; private boolean writeClosed; @@ -52,69 +63,15 @@ public class AsyncContent implements Content.Sink, Content.Source, Closeable *

The write completes:

*
    *
  • immediately with a failure when this instance is closed or already in error
  • - *
  • successfully when the {@link Content.Chunk} returned by {@link #read()} is released
  • - *
  • successfully just before the {@link Content.Chunk} is returned if the latter {@link Content.Chunk#hasRemaining() has no remaining byte}
  • + *
  • successfully when a non empty {@link Content.Chunk} returned by {@link #read()} is released
  • + *
  • successfully just before the {@link Content.Chunk} is returned by {@link #read()}, + * for any empty chunk {@link Content.Chunk}.
  • *
*/ @Override public void write(boolean last, ByteBuffer byteBuffer, Callback callback) { - // Since the contract is that the callback has to be succeeded when - // the chunk returned by read() is released, and since it is not - // possible to create chunks with no remaining byte, when the byte - // buffer is empty we need to replace it with EOF / EMPTY and cannot - // be notified about the release of the latter two. - // This is why read() succeeds the callback if it has no remaining - // byte, meaning it is either EOF or EMPTY. The callback is succeeded - // once and only once, but that happens either during read() if the - // byte buffer is empty or during Chunk.release() if it contains at - // least one byte. - Content.Chunk chunk; - if (byteBuffer.hasRemaining()) - chunk = Content.Chunk.from(byteBuffer, last, callback::succeeded); - else - chunk = last ? Content.Chunk.EOF : Content.Chunk.EMPTY; - offer(chunk, callback); - } - - /** - *

Writes the given {@link Content.Chunk}, notifying the {@link Callback} when the - * write is complete.

- *

The callback completes:

- *
    - *
  • immediately with a failure when this instance is closed or already in error
  • - *
  • immediately with a failure when the written chunk is an instance of {@link Content.Chunk.Error}
  • - *
  • successfully when the {@link Content.Chunk} returned by {@link #read()} is released
  • - *
  • successfully just before the {@link Content.Chunk} is returned if the latter {@link Content.Chunk#hasRemaining() has no remaining byte}
  • - *
- * - * @param chunk the Content.Chunk to write - * @param callback the callback to notify when the write operation is complete - */ - public void write(Content.Chunk chunk, Callback callback) - { - // Non-empty, chunks have to be wrapped to bind the succeeding - // of the callback to the release of the chunk. Empty chunks - // cannot be wrapped, so the callback is succeeded in read() - // for them. - Content.Chunk c; - if (chunk.isTerminal()) - { - c = chunk; - } - else if (!chunk.hasRemaining()) - { - c = Content.Chunk.EMPTY; - } - else - { - c = Content.Chunk.from(chunk.getByteBuffer(), chunk.isLast(), () -> - { - chunk.release(); - callback.succeeded(); - }); - } - offer(c, callback); + offer(new AsyncChunk(last, byteBuffer, callback)); } /** @@ -122,7 +79,7 @@ else if (!chunk.hasRemaining()) * or succeeded if and only if the chunk is terminal, as non-terminal * chunks have to bind the succeeding of the callback to their release. */ - private void offer(Content.Chunk chunk, Callback callback) + private void offer(AsyncChunk chunk) { Throwable failure = null; boolean wasEmpty = false; @@ -136,65 +93,62 @@ else if (errorChunk != null) { failure = errorChunk.getCause(); } - else if (chunk instanceof Content.Chunk.Error error) - { - errorChunk = error; - failure = errorChunk.getCause(); - wasEmpty = chunks.isEmpty(); - } else { wasEmpty = chunks.isEmpty(); - chunks.offer(new ChunkCallback(chunk, callback)); + // No need to retain the chunk, because it's created internally + // from a ByteBuffer and it will be released by the caller of read(). + chunks.offer(chunk); if (chunk.isLast()) { writeClosed = true; if (length == UNDETERMINED_LENGTH) - length = chunks.stream().mapToLong(cc -> cc.chunk().remaining()).sum(); + { + length = 0; + for (AsyncChunk c : chunks) + length += c.remaining(); + } } } } if (failure != null) - callback.failed(failure); + chunk.failed(failure); if (wasEmpty) invoker.run(this::invokeDemandCallback); } public void flush() throws IOException { - try (AutoLock.WithCondition l = lock.lock()) + try (AutoLock.WithCondition condition = lock.lock()) { - try + while (true) { - while (true) + // Always wrap the exception to make sure + // the stack trace comes from flush(). + if (errorChunk != null) + throw new IOException(errorChunk.getCause()); + if (chunks.isEmpty()) + return; + // Special case for a last empty chunk that may not be read. + if (writeClosed && chunks.size() == 1) { - // Always wrap the exception to make sure - // the stack trace comes from flush(). - if (errorChunk != null) - throw new IOException(errorChunk.getCause()); - if (chunks.isEmpty()) + AsyncChunk chunk = chunks.peek(); + if (chunk.isLast() && !chunk.hasRemaining()) return; - // Special case for a last empty chunk that may not be read. - if (writeClosed && chunks.size() == 1) - { - Content.Chunk chunk = chunks.peek().chunk(); - if (chunk.isTerminal()) - return; - } - l.await(); } - } - catch (InterruptedException x) - { - throw new InterruptedIOException(); + condition.await(); } } + catch (InterruptedException x) + { + throw new InterruptedIOException(); + } } @Override public void close() { - write(Content.Chunk.EOF, Callback.NOOP); + offer(ASYNC_EOF); } public boolean isClosed() @@ -217,8 +171,8 @@ public long getLength() @Override public Content.Chunk read() { - ChunkCallback current; - try (AutoLock.WithCondition l = lock.lock()) + AsyncChunk current; + try (AutoLock.WithCondition condition = lock.lock()) { if (length == UNDETERMINED_LENGTH) length = -1; @@ -231,13 +185,18 @@ public Content.Chunk read() return errorChunk; return null; } - readClosed = current.chunk().isLast(); + readClosed = current.isLast(); if (chunks.isEmpty()) - l.signal(); + condition.signal(); } - if (!current.chunk().hasRemaining()) - current.callback().succeeded(); - return current.chunk(); + + // If the chunk is reference counted, the callback is succeeded when it is released. + if (current.canRetain()) + return current; + + // If the chunk is not reference counted, we can succeed it now and return a chunk with a noop release. + current.succeeded(); + return current.isLast() ? Content.Chunk.EOF : Content.Chunk.EMPTY; } @Override @@ -282,8 +241,8 @@ private void runDemandCallback(Runnable demandCallback) @Override public void fail(Throwable failure) { - List drained; - try (AutoLock ignored = lock.lock()) + List drained; + try (AutoLock.WithCondition condition = lock.lock()) { if (readClosed) return; @@ -292,8 +251,9 @@ public void fail(Throwable failure) errorChunk = Content.Chunk.from(failure); drained = List.copyOf(chunks); chunks.clear(); + condition.signal(); } - drained.forEach(cc -> cc.callback().failed(failure)); + drained.forEach(ac -> ac.failed(failure)); invoker.run(this::invokeDemandCallback); } @@ -305,7 +265,52 @@ public int count() } } - private record ChunkCallback(Content.Chunk chunk, Callback callback) + private static class AsyncChunk extends ByteBufferChunk implements Callback { + private final Callback callback; + private final Retainable.ReferenceCounter referenceCounter; + + public AsyncChunk(boolean last, ByteBuffer byteBuffer, Callback callback) + { + super(byteBuffer.hasRemaining() ? byteBuffer : BufferUtil.EMPTY_BUFFER, last); + this.callback = callback; + referenceCounter = getByteBuffer() == BufferUtil.EMPTY_BUFFER ? null : new ReferenceCounter(); + } + + @Override + public boolean canRetain() + { + return referenceCounter != null; + } + + @Override + public void retain() + { + if (canRetain()) + referenceCounter.retain(); + } + + @Override + public boolean release() + { + if (!canRetain()) + return true; + boolean released = referenceCounter.release(); + if (released) + succeeded(); + return released; + } + + @Override + public void succeeded() + { + callback.succeeded(); + } + + @Override + public void failed(Throwable x) + { + callback.failed(x); + } } } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ChunksContentSource.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ChunksContentSource.java index a4c44d9ad819..f4433f564887 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ChunksContentSource.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ChunksContentSource.java @@ -115,7 +115,7 @@ private void runDemandCallback(Runnable demandCallback) @Override public void fail(Throwable failure) { - List toFail = List.of(); + List chunksToRelease; try (AutoLock ignored = lock.lock()) { if (terminated != null) @@ -123,10 +123,14 @@ public void fail(Throwable failure) terminated = Content.Chunk.from(failure); if (iterator != null) { - toFail = new ArrayList<>(); - iterator.forEachRemaining(toFail::add); + chunksToRelease = new ArrayList<>(); + iterator.forEachRemaining(chunksToRelease::add); + } + else + { + chunksToRelease = List.copyOf(chunks); } } - toFail.forEach(Content.Chunk::release); + chunksToRelease.forEach(Content.Chunk::release); } } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSinkSubscriber.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSinkSubscriber.java index c8ceb43f6701..a69de2a9d0f1 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSinkSubscriber.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSinkSubscriber.java @@ -47,6 +47,8 @@ public void onSubscribe(Flow.Subscription subscription) @Override public void onNext(Content.Chunk chunk) { + // Retain the chunk because the write may not complete immediately. + chunk.retain(); sink.write(chunk.isLast(), chunk.getByteBuffer(), Callback.from(() -> succeeded(chunk), x -> failed(chunk, x))); } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java index 9f97ea6556f4..eaf72974379a 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java @@ -133,6 +133,7 @@ private void process() } subscriber.onNext(chunk); + chunk.release(); if (chunk.isLast()) { diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java index e38970eddf3c..167317f425aa 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java @@ -82,24 +82,26 @@ public Content.Chunk read() return Content.Chunk.EOF; } + RetainableByteBuffer streamBuffer = bufferPool.acquire(getBufferSize(), false); try { - RetainableByteBuffer streamBuffer = bufferPool.acquire(getBufferSize(), false); ByteBuffer buffer = streamBuffer.getBuffer(); int read = inputStream.read(buffer.array(), buffer.arrayOffset(), buffer.capacity()); if (read < 0) { + streamBuffer.release(); close(); return Content.Chunk.EOF; } else { buffer.limit(read); - return Content.Chunk.from(buffer, false, streamBuffer); + return Content.Chunk.asChunk(buffer, false, streamBuffer); } } catch (Throwable x) { + streamBuffer.release(); return failure(x); } } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java index 72499202bc9b..5c3491c649b3 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java @@ -146,6 +146,7 @@ public Content.Chunk read() } catch (Throwable x) { + retainableByteBuffer.release(); return failure(x); } @@ -156,7 +157,7 @@ public Content.Chunk read() if (last) IO.close(channel); - return Content.Chunk.from(byteBuffer, last, retainableByteBuffer); + return Content.Chunk.asChunk(byteBuffer, last, retainableByteBuffer); } protected SeekableByteChannel open() throws IOException diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ByteBufferChunk.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ByteBufferChunk.java index 03e216c52390..0baa4199ce1b 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ByteBufferChunk.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ByteBufferChunk.java @@ -24,23 +24,6 @@ public abstract class ByteBufferChunk implements Content.Chunk { - public static final ByteBufferChunk EMPTY = new ByteBufferChunk(BufferUtil.EMPTY_BUFFER, false) - { - @Override - public String toString() - { - return "%s[EMPTY]".formatted(ByteBufferChunk.class.getSimpleName()); - } - }; - public static final ByteBufferChunk EOF = new ByteBufferChunk(BufferUtil.EMPTY_BUFFER, true) - { - @Override - public String toString() - { - return "%s[EOF]".formatted(ByteBufferChunk.class.getSimpleName()); - } - }; - private final ByteBuffer byteBuffer; private final boolean last; @@ -62,18 +45,6 @@ public boolean isLast() return last; } - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } - @Override public String toString() { @@ -94,6 +65,12 @@ public WithReferenceCount(ByteBuffer byteBuffer, boolean last) super(byteBuffer, last); } + @Override + public boolean canRetain() + { + return true; + } + @Override public void retain() { @@ -165,6 +142,12 @@ public WithRetainable(ByteBuffer byteBuffer, boolean last, Retainable retainable this.retainable = retainable; } + @Override + public boolean canRetain() + { + return true; + } + @Override public void retain() { diff --git a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncContentTest.java b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncContentTest.java index 854ec495880c..78f8616e5097 100644 --- a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncContentTest.java +++ b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncContentTest.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.io; -import java.io.IOException; import java.nio.ByteBuffer; import java.util.List; import java.util.concurrent.CancellationException; @@ -24,13 +23,12 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.io.content.AsyncContent; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.thread.Invocable; import org.junit.jupiter.api.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; @@ -53,12 +51,13 @@ public void testWriteInvokesDemandCallback() throws Exception async.demand(latch::countDown); assertFalse(latch.await(250, TimeUnit.MILLISECONDS)); - async.write(Content.Chunk.from(UTF_8.encode("one"), false), Callback.NOOP); + async.write(false, UTF_8.encode("one"), Callback.NOOP); assertTrue(latch.await(5, TimeUnit.SECONDS)); Content.Chunk chunk = async.read(); assertNotNull(chunk); + chunk.release(); } } @@ -77,6 +76,7 @@ public void testCloseInvokesDemandCallback() throws Exception Content.Chunk chunk = async.read(); assertNotNull(chunk); + chunk.release(); assertTrue(chunk.isLast()); } @@ -85,10 +85,11 @@ public void testFailInvokesDemandCallback() throws Exception { try (AsyncContent async = new AsyncContent()) { - async.write(Content.Chunk.from(UTF_8.encode("one"), false), Callback.NOOP); + async.write(false, UTF_8.encode("one"), Callback.NOOP); Content.Chunk chunk = async.read(); assertNotNull(chunk); + chunk.release(); CountDownLatch latch = new CountDownLatch(1); async.demand(latch::countDown); @@ -104,34 +105,11 @@ public void testFailInvokesDemandCallback() throws Exception // Offering more should fail. CountDownLatch failLatch = new CountDownLatch(1); - async.write(Content.Chunk.EMPTY, Callback.from(Callback.NOOP::succeeded, x -> failLatch.countDown())); + async.write(false, BufferUtil.EMPTY_BUFFER, Callback.from(Callback.NOOP::succeeded, x -> failLatch.countDown())); assertTrue(failLatch.await(5, TimeUnit.SECONDS)); } } - @Test - public void testWriteErrorChunk() throws Exception - { - try (AsyncContent async = new AsyncContent()) - { - CountDownLatch latch = new CountDownLatch(1); - async.demand(latch::countDown); - assertFalse(latch.await(250, TimeUnit.MILLISECONDS)); - - Throwable error = new Throwable("test"); - AtomicReference callback = new AtomicReference<>(); - async.write(Content.Chunk.from(error), Callback.from(Invocable.NOOP, callback::set)); - - assertThat(callback.get(), sameInstance(error)); - assertTrue(latch.await(5, TimeUnit.SECONDS)); - - Content.Chunk chunk = async.read(); - assertNotNull(chunk); - assertThat(chunk, instanceOf(Content.Chunk.Error.class)); - assertThat(((Content.Chunk.Error)chunk).getCause(), sameInstance(error)); - } - } - @Test public void testChunkReleaseSucceedsWriteCallback() { @@ -165,7 +143,8 @@ public void testEmptyChunkReadSucceedsWriteCallback() Content.Chunk chunk = async.read(); assertThat(successCounter.get(), is(1)); - assertThat(chunk.isTerminal(), is(false)); + assertThat(chunk.isLast(), is(false)); + assertThat(chunk.hasRemaining(), is(false)); assertThat(chunk.release(), is(true)); assertThat(successCounter.get(), is(1)); assertThat(failureRef.get(), is(nullValue())); @@ -184,7 +163,8 @@ public void testLastEmptyChunkReadSucceedsWriteCallback() Content.Chunk chunk = async.read(); assertThat(successCounter.get(), is(1)); - assertThat(chunk.isTerminal(), is(true)); + assertThat(chunk.isLast(), is(true)); + assertThat(chunk.hasRemaining(), is(false)); assertThat(chunk.release(), is(true)); assertThat(successCounter.get(), is(1)); assertThat(failureRef.get(), is(nullValue())); @@ -192,52 +172,23 @@ public void testLastEmptyChunkReadSucceedsWriteCallback() } @Test - public void testWriteAndReadErrors() - { - try (AsyncContent async = new AsyncContent()) - { - AssertingCallback callback = new AssertingCallback(); - - Exception error1 = new Exception("error1"); - async.write(Content.Chunk.from(error1), callback); - callback.assertSingleFailureSameInstanceNoSuccess(error1); - - Content.Chunk chunk = async.read(); - assertThat(((Content.Chunk.Error)chunk).getCause(), sameInstance(error1)); - chunk = async.read(); - assertThat(((Content.Chunk.Error)chunk).getCause(), sameInstance(error1)); - callback.assertNoFailureNoSuccess(); - - Exception error2 = new Exception("error2"); - async.write(Content.Chunk.from(error2), callback); - callback.assertSingleFailureSameInstanceNoSuccess(error1); - - async.write(Content.Chunk.from(ByteBuffer.wrap(new byte[1]), false), callback); - callback.assertSingleFailureSameInstanceNoSuccess(error1); - } - } - - @Test - public void testCloseAfterWritingEof() + public void testReadAfterClose() { - AssertingCallback callback = new AssertingCallback(); try (AsyncContent async = new AsyncContent()) { - async.write(Content.Chunk.EOF, callback); - callback.assertNoFailureNoSuccess(); - - Content.Chunk chunk = async.read(); - assertThat(chunk.isTerminal(), is(true)); - callback.assertNoFailureWithSuccesses(1); - - chunk = async.read(); - assertThat(chunk.isTerminal(), is(true)); - callback.assertNoFailureWithSuccesses(0); - - async.write(Content.Chunk.EOF, callback); - callback.assertSingleFailureIsInstanceNoSuccess(IOException.class); + async.close(); + + Content.Chunk chunk1 = async.read(); + assertThat(chunk1.isLast(), is(true)); + assertThat(chunk1.hasRemaining(), is(false)); + chunk1.release(); + + Content.Chunk chunk2 = async.read(); + assertThat(chunk2.isLast(), is(true)); + assertThat(chunk2.hasRemaining(), is(false)); + assertSame(chunk1, chunk2); + chunk2.release(); } - callback.assertNoFailureNoSuccess(); } @Test @@ -318,12 +269,5 @@ public void assertSingleFailureSameInstanceNoSuccess(Throwable x) assertThat(throwables.size(), is(1)); assertThat(throwables.remove(0), sameInstance(x)); } - - public void assertSingleFailureIsInstanceNoSuccess(Class clazz) - { - assertThat(successCounter.get(), is(0)); - assertThat(throwables.size(), is(1)); - assertThat(throwables.remove(0), instanceOf(clazz)); - } } } diff --git a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTest.java b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTest.java index 239c459074d5..654cc18dc0fe 100644 --- a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTest.java +++ b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTest.java @@ -64,8 +64,8 @@ public static List all() throws Exception AsyncContent asyncSource = new AsyncContent(); try (asyncSource) { - asyncSource.write(Content.Chunk.from(UTF_8.encode("one"), false), Callback.NOOP); - asyncSource.write(Content.Chunk.from(UTF_8.encode("two"), false), Callback.NOOP); + asyncSource.write(false, UTF_8.encode("one"), Callback.NOOP); + asyncSource.write(false, UTF_8.encode("two"), Callback.NOOP); } ByteBufferContentSource byteBufferSource = new ByteBufferContentSource(UTF_8.encode("one"), UTF_8.encode("two")); @@ -186,6 +186,7 @@ public void run() Content.Chunk chunk = source.read(); assertNotNull(chunk); + chunk.release(); // Demand again, it must not recurse. if (!chunk.isLast()) @@ -209,6 +210,7 @@ public void run() { Content.Chunk chunk = source.read(); assertNotNull(chunk); + chunk.release(); if (!chunk.isLast()) { @@ -229,6 +231,7 @@ public void testReadFailReadReturnsError(Content.Source source) throws Exception { Content.Chunk chunk = nextChunk(source); assertNotNull(chunk); + chunk.release(); source.fail(new CancellationException()); @@ -274,6 +277,7 @@ public void testDemandCallbackThrows(Content.Source source) throws Exception Content.Chunk chunk = nextChunk(source); assertNotNull(chunk); + chunk.release(); source.demand(() -> { @@ -520,6 +524,8 @@ private Runnable takeDemand() private void add(Content.Chunk chunk) { + // Retain the chunk because it is stored for later use. + chunk.retain(); _chunks.add(chunk); } diff --git a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTransformerTest.java b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTransformerTest.java index a09a0e53dd47..e8dc25a046ff 100644 --- a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTransformerTest.java +++ b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentSourceTransformerTest.java @@ -54,12 +54,13 @@ public void testNoChunks() transformer.demand(callback::succeeded); assertFalse(callback.isDone()); - source.write(Content.Chunk.EOF, Callback.NOOP); + source.close(); assertTrue(callback.isDone()); chunk = transformer.read(); assertNotNull(chunk); + chunk.release(); assertTrue(chunk.isLast()); } @@ -68,23 +69,26 @@ public void testNoChunks() public void testTwoChunksAndEOF(boolean last) { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE two"), last), Callback.NOOP); + source.write(last, UTF_8.encode("ONE two"), Callback.NOOP); if (!last) - source.write(Content.Chunk.EOF, Callback.NOOP); + source.close(); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals("one", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); chunk = transformer.read(); assertNotNull(chunk); assertEquals("two", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); if (last) assertTrue(chunk.isLast()); chunk = transformer.read(); assertNotNull(chunk); + chunk.release(); assertTrue(chunk.isLast()); } @@ -92,7 +96,7 @@ public void testTwoChunksAndEOF(boolean last) public void testDemandFirstWithLoop() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE two"), true), Callback.NOOP); + source.write(true, UTF_8.encode("ONE two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); AtomicBoolean processed = new AtomicBoolean(); @@ -103,6 +107,7 @@ public void testDemandFirstWithLoop() { Content.Chunk chunk = transformer.read(); assertNotNull(chunk); + chunk.release(); if (chunk.isLast()) break; } @@ -115,7 +120,7 @@ public void testDemandFirstWithLoop() public void testDemandFirstWithoutLoop() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE NOOP two"), true), Callback.NOOP); + source.write(true, UTF_8.encode("ONE NOOP two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); AtomicBoolean reEnter = new AtomicBoolean(); @@ -131,6 +136,7 @@ public void run() Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals(expected.poll(), UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); if (!chunk.isLast()) transformer.demand(this); @@ -147,7 +153,7 @@ public void run() public void testDemandFirstWithoutLoopStallAfterTwoExpectedChunks() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE NOOP two"), false), Callback.NOOP); + source.write(false, UTF_8.encode("ONE NOOP two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); AtomicBoolean reEnter = new AtomicBoolean(); @@ -162,7 +168,10 @@ public void run() Content.Chunk chunk = transformer.read(); if (chunk != null) + { assertEquals(expected.poll(), UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); + } if (chunk == null || !chunk.isLast()) transformer.demand(this); @@ -175,7 +184,7 @@ public void run() assertThat(expected, empty()); expected.offer("three"); - source.write(Content.Chunk.from(UTF_8.encode("three"), true), Callback.NOOP); + source.write(true, UTF_8.encode("three"), Callback.NOOP); assertThat(expected, empty()); expected.offer("EOF"); @@ -184,6 +193,7 @@ public void run() Content.Chunk chunk = transformer.read(); assertTrue(chunk.isLast()); assertFalse(chunk.hasRemaining()); + chunk.release(); expected.poll(); }); @@ -194,7 +204,7 @@ public void run() public void testDemandFirstThenConsumeAllChunks() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE NOOP two"), true), Callback.NOOP); + source.write(true, UTF_8.encode("ONE NOOP two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); AtomicInteger count = new AtomicInteger(); @@ -213,6 +223,7 @@ public void run() Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals("one", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); // This demand will be fulfilled later after the last chunk has been read. transformer.demand(this); @@ -221,6 +232,7 @@ public void run() assertNotNull(chunk); assertEquals("two", UTF_8.decode(chunk.getByteBuffer()).toString()); assertTrue(chunk.isLast()); + chunk.release(); if (!reEnter.compareAndSet(true, false)) throw new IllegalStateException(); @@ -236,14 +248,15 @@ public void run() public void testTransformThrows() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE"), false), Callback.NOOP); - source.write(Content.Chunk.from(UTF_8.encode("THROW"), false), Callback.NOOP); - source.write(Content.Chunk.from(UTF_8.encode("two"), true), Callback.NOOP); + source.write(false, UTF_8.encode("ONE"), Callback.NOOP); + source.write(false, UTF_8.encode("THROW"), Callback.NOOP); + source.write(true, UTF_8.encode("two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals("one", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); chunk = transformer.read(); assertInstanceOf(Content.Chunk.Error.class, chunk); @@ -260,14 +273,15 @@ public void testTransformThrows() public void testTransformReturnsError() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE"), false), Callback.NOOP); - source.write(Content.Chunk.from(UTF_8.encode("ERROR"), false), Callback.NOOP); - source.write(Content.Chunk.from(UTF_8.encode("two"), true), Callback.NOOP); + source.write(false, UTF_8.encode("ONE"), Callback.NOOP); + source.write(false, UTF_8.encode("ERROR"), Callback.NOOP); + source.write(true, UTF_8.encode("two"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals("one", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); chunk = transformer.read(); assertInstanceOf(Content.Chunk.Error.class, chunk); @@ -281,13 +295,15 @@ public void testTransformReturnsError() public void testSourceReturnsError() { AsyncContent source = new AsyncContent(); - source.write(Content.Chunk.from(UTF_8.encode("ONE"), false), Callback.NOOP); - source.write(Content.Chunk.from(new IOException()), Callback.NOOP); + source.write(false, UTF_8.encode("ONE"), Callback.NOOP); WordSplitLowCaseTransformer transformer = new WordSplitLowCaseTransformer(source); Content.Chunk chunk = transformer.read(); assertNotNull(chunk); assertEquals("one", UTF_8.decode(chunk.getByteBuffer()).toString()); + chunk.release(); + + source.fail(new IOException()); chunk = transformer.read(); assertInstanceOf(Content.Chunk.Error.class, chunk); @@ -333,7 +349,6 @@ protected Content.Chunk transform(Content.Chunk rawChunk) if (rawChunk.isLast() && !last) chunks.offer(Content.Chunk.EOF); } - return chunks.poll(); } } diff --git a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentTest.java b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentTest.java index a09d6e1fb908..0a3e4c0ec9e7 100644 --- a/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentTest.java +++ b/jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/ContentTest.java @@ -66,13 +66,13 @@ public void testFromEmptyByteBufferWithRetainableReleaser() { Retainable.ReferenceCounter referenceCounter1 = new Retainable.ReferenceCounter(2); assertThat(referenceCounter1.isRetained(), is(true)); - assertThat(Content.Chunk.from(ByteBuffer.wrap(new byte[0]), true, referenceCounter1), sameInstance(Content.Chunk.EOF)); + assertThat(Content.Chunk.asChunk(ByteBuffer.wrap(new byte[0]), true, referenceCounter1), sameInstance(Content.Chunk.EOF)); assertThat(referenceCounter1.isRetained(), is(false)); assertThat(referenceCounter1.release(), is(true)); Retainable.ReferenceCounter referenceCounter2 = new Retainable.ReferenceCounter(2); assertThat(referenceCounter2.isRetained(), is(true)); - assertThat(Content.Chunk.from(ByteBuffer.wrap(new byte[0]), false, referenceCounter2), sameInstance(Content.Chunk.EMPTY)); + assertThat(Content.Chunk.asChunk(ByteBuffer.wrap(new byte[0]), false, referenceCounter2), sameInstance(Content.Chunk.EMPTY)); assertThat(referenceCounter2.isRetained(), is(false)); assertThat(referenceCounter2.release(), is(true)); } diff --git a/jetty-core/jetty-keystore/src/test/java/org/eclipse/jetty/test/keystore/KeystoreGeneratorTest.java b/jetty-core/jetty-keystore/src/test/java/org/eclipse/jetty/test/keystore/KeystoreGeneratorTest.java index 5b8572ead19e..9a1f52fe1ee3 100644 --- a/jetty-core/jetty-keystore/src/test/java/org/eclipse/jetty/test/keystore/KeystoreGeneratorTest.java +++ b/jetty-core/jetty-keystore/src/test/java/org/eclipse/jetty/test/keystore/KeystoreGeneratorTest.java @@ -16,9 +16,9 @@ import java.io.File; import java.nio.file.Path; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-core/jetty-osgi/pom.xml b/jetty-core/jetty-osgi/pom.xml index 0cf1afb17280..9dcc30abeca9 100644 --- a/jetty-core/jetty-osgi/pom.xml +++ b/jetty-core/jetty-osgi/pom.xml @@ -13,19 +13,6 @@ ${project.groupId}.osgi org.eclipse.jetty.osgi.* - 3.18.100 - 3.11.0 - 1.6.1 - 1.5.0 - 1.4.1 - 3.7.100 - 1.2.0 - 1.2.0 - 1.0.2 - 1.0.1 - 1.5.4 - 1.0.2 - 1.0.0-v20070606 true @@ -53,58 +40,6 @@ - - - - org.eclipse.platform - org.eclipse.osgi.services - ${osgi-services-version} - - - - jakarta.servlet - servlet-api - - - - org.apache.felix - org.osgi.foundation - - - - - - org.eclipse.platform - org.eclipse.osgi - ${osgi-version} - - - org.osgi - org.osgi.service.cm - ${osgi-service-cm-version} - - - org.osgi - org.osgi.service.component - ${osgi-service-component-version} - - - org.osgi - org.osgi.service.event - ${osgi-service-event-version} - - - org.osgi - org.osgi.util.tracker - ${osgi-util-tracker-version} - - - org.eclipse.equinox.http - servlet - ${equinox-http-servlet-version} - - - @@ -139,7 +74,6 @@ org.osgi org.osgi.util.tracker - org.slf4j slf4j-api diff --git a/jetty-core/jetty-proxy/pom.xml b/jetty-core/jetty-proxy/pom.xml index 18f0f92a2a79..8c8c350f329b 100644 --- a/jetty-core/jetty-proxy/pom.xml +++ b/jetty-core/jetty-proxy/pom.xml @@ -16,6 +16,21 @@ ${project.groupId}.proxy + + + + maven-surefire-plugin + + + @{argLine} + ${jetty.surefire.argLine} + --add-exports org.eclipse.jetty.client/org.eclipse.jetty.client.internal=ALL-UNNAMED + + + + + + org.slf4j diff --git a/jetty-core/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyHandler.java b/jetty-core/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyHandler.java index 6fc7ce7a2e4d..cfd72e8b243e 100644 --- a/jetty-core/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyHandler.java +++ b/jetty-core/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyHandler.java @@ -27,14 +27,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.client.ContinueProtocolHandler; import org.eclipse.jetty.client.EarlyHintsProtocolHandler; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.ProcessingProtocolHandler; import org.eclipse.jetty.client.ProtocolHandlers; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; @@ -248,7 +248,7 @@ public boolean process(Request clientToProxyRequest, Response proxyToClientRespo LOG.debug("{} P2S continuing request", requestId(clientToProxyRequest)); var proxyToServerRequestContent = newProxyToServerRequestContent(clientToProxyRequest, proxyToClientResponse, proxyToServerRequest); Content.copy(proxyToServerRequestContent, delayedProxyToServerRequestContent, - Callback.from(delayedProxyToServerRequestContent::close, x -> delayedProxyToServerRequestContent.write(Content.Chunk.from(x), Callback.NOOP))); + Callback.from(delayedProxyToServerRequestContent::close, delayedProxyToServerRequestContent::fail)); }; proxyToServerRequest.attribute(PROXY_TO_SERVER_CONTINUE_ATTRIBUTE, action); } @@ -271,13 +271,13 @@ public boolean process(Request clientToProxyRequest, Response proxyToClientRespo */ protected abstract HttpURI rewriteHttpURI(Request clientToProxyRequest); - protected org.eclipse.jetty.client.api.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) + protected org.eclipse.jetty.client.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) { return getHttpClient().newRequest(newHttpURI.toURI()) .method(clientToProxyRequest.getMethod()); } - protected void copyRequestHeaders(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void copyRequestHeaders(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest) { Set headersToRemove = findConnectionHeaders(clientToProxyRequest); @@ -324,13 +324,13 @@ private Set findConnectionHeaders(Request clientToProxyRequest) return hopHeaders; } - protected void addProxyHeaders(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void addProxyHeaders(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest) { addViaHeader(clientToProxyRequest, proxyToServerRequest); addForwardedHeader(clientToProxyRequest, proxyToServerRequest); } - protected void addViaHeader(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void addViaHeader(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest) { String protocol = clientToProxyRequest.getConnectionMetaData().getProtocol(); String[] parts = protocol.split("/", 2); @@ -353,7 +353,7 @@ protected void addViaHeader(Request clientToProxyRequest, org.eclipse.jetty.clie })); } - protected void addForwardedHeader(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void addForwardedHeader(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest) { String byAttr = Request.getLocalAddr(clientToProxyRequest); String forAttr = Request.getRemoteAddr(clientToProxyRequest); @@ -403,12 +403,12 @@ private boolean expects100Continue(Request clientToProxyRequest) return HttpHeaderValue.CONTINUE.is(clientToProxyRequest.getHeaders().get(HttpHeader.EXPECT)); } - protected org.eclipse.jetty.client.api.Request.Content newProxyToServerRequestContent(Request clientToProxyRequest, Response proxyToClientResponse, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected org.eclipse.jetty.client.Request.Content newProxyToServerRequestContent(Request clientToProxyRequest, Response proxyToClientResponse, org.eclipse.jetty.client.Request proxyToServerRequest) { return new ProxyRequestContent(clientToProxyRequest); } - protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) + protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) { if (LOG.isDebugEnabled()) { @@ -423,7 +423,7 @@ protected void sendProxyToServerRequest(Request clientToProxyRequest, org.eclips proxyToServerRequest.send(newServerToProxyResponseListener(clientToProxyRequest, proxyToServerRequest, proxyToClientResponse, proxyToClientCallback)); } - protected org.eclipse.jetty.client.api.Response.CompleteListener newServerToProxyResponseListener(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) + protected org.eclipse.jetty.client.Response.CompleteListener newServerToProxyResponseListener(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) { return new ProxyResponseListener(clientToProxyRequest, proxyToServerRequest, proxyToClientResponse, proxyToClientCallback); } @@ -433,7 +433,7 @@ protected HttpField filterServerToProxyResponseField(HttpField serverToProxyResp return serverToProxyResponseField; } - protected void onServerToProxyResponseFailure(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, org.eclipse.jetty.client.api.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback, Throwable failure) + protected void onServerToProxyResponseFailure(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.client.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback, Throwable failure) { int status = HttpStatus.BAD_GATEWAY_502; if (failure instanceof TimeoutException) @@ -442,7 +442,7 @@ protected void onServerToProxyResponseFailure(Request clientToProxyRequest, org. Response.writeError(clientToProxyRequest, proxyToClientResponse, callback, status); } - protected void onServerToProxyResponse100Continue(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void onServerToProxyResponse100Continue(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest) { if (LOG.isDebugEnabled()) LOG.debug("{} P2C 100 continue response", requestId(clientToProxyRequest)); @@ -450,26 +450,26 @@ protected void onServerToProxyResponse100Continue(Request clientToProxyRequest, action.run(); } - protected void onServerToProxyResponse102Processing(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders, Response proxyToClientResponse) + protected void onServerToProxyResponse102Processing(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders, Response proxyToClientResponse) { if (LOG.isDebugEnabled()) LOG.debug("{} P2C 102 interim response {}", requestId(clientToProxyRequest), serverToProxyResponseHeaders); proxyToClientResponse.writeInterim(HttpStatus.PROCESSING_102, serverToProxyResponseHeaders); } - protected void onServerToProxyResponse103EarlyHints(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders, Response proxyToClientResponse) + protected void onServerToProxyResponse103EarlyHints(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders, Response proxyToClientResponse) { if (LOG.isDebugEnabled()) LOG.debug("{} P2C 103 interim response {}", requestId(clientToProxyRequest), serverToProxyResponseHeaders); proxyToClientResponse.writeInterim(HttpStatus.EARLY_HINT_103, serverToProxyResponseHeaders); } - protected void onProxyToClientResponseComplete(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, org.eclipse.jetty.client.api.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback) + protected void onProxyToClientResponseComplete(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.client.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback) { proxyToClientCallback.succeeded(); } - protected void onProxyToClientResponseFailure(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, org.eclipse.jetty.client.api.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback, Throwable failure) + protected void onProxyToClientResponseFailure(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.client.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback, Throwable failure) { // There is no point trying to write an error, // we already know we cannot write to the client. @@ -577,7 +577,7 @@ protected HttpURI rewriteHttpURI(Request clientToProxyRequest) } } - protected static class ProxyRequestContent implements org.eclipse.jetty.client.api.Request.Content + protected static class ProxyRequestContent implements org.eclipse.jetty.client.Request.Content { private final Request clientToProxyRequest; @@ -626,14 +626,14 @@ public boolean rewind() } } - protected class ProxyResponseListener extends Callback.Completable implements org.eclipse.jetty.client.api.Response.Listener + protected class ProxyResponseListener extends Callback.Completable implements org.eclipse.jetty.client.Response.Listener { private final Request clientToProxyRequest; - private final org.eclipse.jetty.client.api.Request proxyToServerRequest; + private final org.eclipse.jetty.client.Request proxyToServerRequest; private final Response proxyToClientResponse; private final Callback proxyToClientCallback; - public ProxyResponseListener(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) + public ProxyResponseListener(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) { this.clientToProxyRequest = clientToProxyRequest; this.proxyToServerRequest = proxyToServerRequest; @@ -642,13 +642,13 @@ public ProxyResponseListener(Request clientToProxyRequest, org.eclipse.jetty.cli } @Override - public void onBegin(org.eclipse.jetty.client.api.Response serverToProxyResponse) + public void onBegin(org.eclipse.jetty.client.Response serverToProxyResponse) { proxyToClientResponse.setStatus(serverToProxyResponse.getStatus()); } @Override - public void onHeaders(org.eclipse.jetty.client.api.Response serverToProxyResponse) + public void onHeaders(org.eclipse.jetty.client.Response serverToProxyResponse) { if (LOG.isDebugEnabled()) { @@ -682,11 +682,13 @@ public void onHeaders(org.eclipse.jetty.client.api.Response serverToProxyRespons } @Override - public void onContent(org.eclipse.jetty.client.api.Response serverToProxyResponse, Content.Chunk serverToProxyChunk, Runnable serverToProxyDemander) + public void onContent(org.eclipse.jetty.client.Response serverToProxyResponse, Content.Chunk serverToProxyChunk, Runnable serverToProxyDemander) { ByteBuffer serverToProxyContent = serverToProxyChunk.getByteBuffer(); if (LOG.isDebugEnabled()) LOG.debug("{} S2P received content {}", requestId(clientToProxyRequest), BufferUtil.toDetailString(serverToProxyContent)); + + serverToProxyChunk.retain(); Callback callback = new Callback() { @Override @@ -714,11 +716,12 @@ public InvocationType getInvocationType() return InvocationType.NON_BLOCKING; } }; + proxyToClientResponse.write(false, serverToProxyContent, callback); } @Override - public void onSuccess(org.eclipse.jetty.client.api.Response serverToProxyResponse) + public void onSuccess(org.eclipse.jetty.client.Response serverToProxyResponse) { proxyToClientResponse.write(true, BufferUtil.EMPTY_BUFFER, this); } @@ -757,12 +760,12 @@ public void onComplete(Result result) private class ProxyToClientResponseFailureCallback implements Callback { private final Request clientToProxyRequest; - private final org.eclipse.jetty.client.api.Request proxyToServerRequest; - private final org.eclipse.jetty.client.api.Response serverToProxyResponse; + private final org.eclipse.jetty.client.Request proxyToServerRequest; + private final org.eclipse.jetty.client.Response serverToProxyResponse; private final Response proxyToClientResponse; private final Callback proxyToClientCallback; - private ProxyToClientResponseFailureCallback(Request clientToProxyRequest, org.eclipse.jetty.client.api.Request proxyToServerRequest, org.eclipse.jetty.client.api.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback) + private ProxyToClientResponseFailureCallback(Request clientToProxyRequest, org.eclipse.jetty.client.Request proxyToServerRequest, org.eclipse.jetty.client.Response serverToProxyResponse, Response proxyToClientResponse, Callback proxyToClientCallback) { this.clientToProxyRequest = clientToProxyRequest; this.proxyToServerRequest = proxyToServerRequest; @@ -797,7 +800,7 @@ public InvocationType getInvocationType() private class ProxyContinueProtocolHandler extends ContinueProtocolHandler { @Override - protected void onContinue(org.eclipse.jetty.client.api.Request proxyToServerRequest) + protected void onContinue(org.eclipse.jetty.client.Request proxyToServerRequest) { super.onContinue(proxyToServerRequest); var clientToProxyRequest = (Request)proxyToServerRequest.getAttributes().get(CLIENT_TO_PROXY_REQUEST_ATTRIBUTE); @@ -810,7 +813,7 @@ protected void onContinue(org.eclipse.jetty.client.api.Request proxyToServerRequ private class ProxyProcessingProtocolHandler extends ProcessingProtocolHandler { @Override - protected void onProcessing(org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders) + protected void onProcessing(org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders) { super.onProcessing(proxyToServerRequest, serverToProxyResponseHeaders); var clientToProxyRequest = (Request)proxyToServerRequest.getAttributes().get(CLIENT_TO_PROXY_REQUEST_ATTRIBUTE); @@ -824,7 +827,7 @@ protected void onProcessing(org.eclipse.jetty.client.api.Request proxyToServerRe private class ProxyEarlyHintsProtocolHandler extends EarlyHintsProtocolHandler { @Override - protected void onEarlyHints(org.eclipse.jetty.client.api.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders) + protected void onEarlyHints(org.eclipse.jetty.client.Request proxyToServerRequest, HttpFields serverToProxyResponseHeaders) { super.onEarlyHints(proxyToServerRequest, serverToProxyResponseHeaders); var clientToProxyRequest = (Request)proxyToServerRequest.getAttributes().get(CLIENT_TO_PROXY_REQUEST_ATTRIBUTE); diff --git a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractProxyTest.java b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractProxyTest.java index 7774c901f77b..02a3f5308964 100644 --- a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractProxyTest.java +++ b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractProxyTest.java @@ -16,8 +16,8 @@ import java.util.List; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.ClientConnectionFactoryOverHTTP2; diff --git a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ForwardProxyWithDynamicTransportTest.java b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ForwardProxyWithDynamicTransportTest.java index 583b652ff3b1..707dc98de087 100644 --- a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ForwardProxyWithDynamicTransportTest.java +++ b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ForwardProxyWithDynamicTransportTest.java @@ -25,14 +25,13 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.AbstractConnectionPool; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HostPortHttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpScheme; @@ -278,10 +277,10 @@ public boolean process(Request request, Response response, Callback callback) assertEquals(status, response2.getStatus()); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == serverPort) + .filter(d -> d.getOrigin().getAddress().getPort() == serverPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(1, connectionPool.getConnectionCount()); } @@ -312,10 +311,10 @@ public void testHTTP2TunnelClosedByClient() throws Exception Thread.sleep(2 * idleTimeout); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == serverPort) + .filter(d -> d.getOrigin().getAddress().getPort() == serverPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(0, connectionPool.getConnectionCount()); @@ -386,10 +385,10 @@ protected void handleConnect(Request request, Response response, Callback callba assertTrue(latch.await(5, TimeUnit.SECONDS)); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == proxyPort) + .filter(d -> d.getOrigin().getAddress().getPort() == proxyPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(0, connectionPool.getConnectionCount()); } diff --git a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/InterimResponseProxyTest.java b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/InterimResponseProxyTest.java index ab4e82a64088..41b87e1f00c8 100644 --- a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/InterimResponseProxyTest.java +++ b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/InterimResponseProxyTest.java @@ -16,8 +16,8 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.CompletableFuture; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; diff --git a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ReverseProxyTest.java b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ReverseProxyTest.java index 8e6f003abaec..ab17d0920e19 100644 --- a/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ReverseProxyTest.java +++ b/jetty-core/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ReverseProxyTest.java @@ -15,11 +15,11 @@ import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http2.client.HTTP2Client; @@ -71,7 +71,7 @@ protected HttpClient newHttpClient() } @Override - protected org.eclipse.jetty.client.api.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) + protected org.eclipse.jetty.client.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) { // Use the client to proxy protocol also from the proxy to server. return super.newProxyToServerRequest(clientToProxyRequest, newHttpURI) @@ -120,7 +120,7 @@ protected HttpClient newHttpClient() } @Override - protected org.eclipse.jetty.client.api.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) + protected org.eclipse.jetty.client.Request newProxyToServerRequest(Request clientToProxyRequest, HttpURI newHttpURI) { // Use the client to proxy protocol also from the proxy to server. return super.newProxyToServerRequest(clientToProxyRequest, newHttpURI) diff --git a/jetty-core/jetty-quic/jetty-quic-client/src/test/java/org/eclipse/jetty/quic/client/End2EndClientTest.java b/jetty-core/jetty-quic/jetty-quic-client/src/test/java/org/eclipse/jetty/quic/client/End2EndClientTest.java index 5028225d6510..aedb846797d7 100644 --- a/jetty-core/jetty-quic/jetty-quic-client/src/test/java/org/eclipse/jetty/quic/client/End2EndClientTest.java +++ b/jetty-core/jetty-quic/jetty-quic-client/src/test/java/org/eclipse/jetty/quic/client/End2EndClientTest.java @@ -16,10 +16,10 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.ClientConnectionFactoryOverHTTP2; diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/FormFields.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/FormFields.java index 4bec6094f72f..787e70a7bc9d 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/FormFields.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/FormFields.java @@ -138,11 +138,12 @@ public FormFields(Content.Source source, Charset charset, int maxFields, int max @Override public void run() { + Content.Chunk chunk = null; try { while (true) { - Content.Chunk chunk = _source.read(); + chunk = _source.read(); if (chunk == null) { _source.demand(this); @@ -163,6 +164,8 @@ public void run() if (_maxFields >= 0 && _fields.getSize() >= _maxFields) { chunk.release(); + // Do not double release if completeExceptionally() throws. + chunk = null; completeExceptionally(new IllegalStateException("form with too many fields")); return; } @@ -172,6 +175,8 @@ public void run() chunk.release(); if (chunk.isLast()) { + // Do not double release if complete() throws. + chunk = null; complete(_fields); return; } @@ -179,6 +184,8 @@ public void run() } catch (Throwable x) { + if (chunk != null) + chunk.release(); completeExceptionally(x); } } @@ -214,7 +221,7 @@ protected Fields.Field parse(Content.Chunk chunk) throws CharacterCodingExceptio case '=' -> { _name = _builder.takeString(); - checkLength(chunk, _name); + checkLength(_name); } case '+' -> _builder.append((byte)' '); case '%' -> _percent++; @@ -228,7 +235,7 @@ protected Fields.Field parse(Content.Chunk chunk) throws CharacterCodingExceptio case '&' -> { value = _builder.takeString(); - checkLength(chunk, value); + checkLength(value); break loop; } case '+' -> _builder.append((byte)' '); @@ -248,7 +255,7 @@ protected Fields.Field parse(Content.Chunk chunk) throws CharacterCodingExceptio _builder.append(_percentCode); } value = _builder.takeString(); - checkLength(chunk, value); + checkLength(value); } if (value != null) @@ -262,16 +269,13 @@ protected Fields.Field parse(Content.Chunk chunk) throws CharacterCodingExceptio return null; } - private void checkLength(Content.Chunk chunk, String nameOrValue) + private void checkLength(String nameOrValue) { if (_maxLength >= 0) { _length += nameOrValue.length(); if (_length > _maxLength) - { - chunk.release(); throw new IllegalStateException("form too large"); - } } } } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DelayedHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DelayedHandler.java index e862905048a2..016aaaa5f192 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DelayedHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DelayedHandler.java @@ -180,13 +180,16 @@ protected void delay() } else { + RewindChunkRequest request = new RewindChunkRequest(getRequest(), chunk); try { - getHandler().process(new RewindChunkRequest(getRequest(), chunk), getResponse(), getCallback()); + getHandler().process(request, getResponse(), getCallback()); } - catch (Exception e) + catch (Throwable x) { - Response.writeError(getRequest(), getResponse(), getCallback(), e); + // Use the wrapped request so that the error handling can + // consume the request content and release the already read chunk. + Response.writeError(request, getResponse(), getCallback(), x); } } } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipRequest.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipRequest.java index 40f9d0bae6a3..a0d8be26483d 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipRequest.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipRequest.java @@ -177,6 +177,7 @@ protected Content.Chunk transform(Content.Chunk inputChunk) } else { + _decoder.release(decodedBuffer); // Could not decode more from this chunk, release it. Content.Chunk result = _chunk.isLast() ? Content.Chunk.EOF : null; _chunk.release(); @@ -195,12 +196,12 @@ private Decoder(InflaterPool inflaterPool, ByteBufferPool bufferPool, int buffer super(inflaterPool, bufferPool, bufferSize); } - public ByteBuffer decode(Content.Chunk content) + public ByteBuffer decode(Content.Chunk chunk) { - decodeChunks(content.getByteBuffer()); - ByteBuffer chunk = _decoded; + decodeChunks(chunk.getByteBuffer()); + ByteBuffer decoded = _decoded; _decoded = null; - return chunk; + return decoded; } @Override diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java index 3deae290d749..2a5196447b23 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java @@ -51,7 +51,6 @@ import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; -import org.eclipse.jetty.io.Retainable; import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.WriteFlusher; @@ -988,13 +987,11 @@ public boolean content(ByteBuffer buffer) if (stream == null || stream._chunk != null || _retainableByteBuffer == null) throw new IllegalStateException(); - _retainableByteBuffer.retain(); - if (LOG.isDebugEnabled()) LOG.debug("content {}/{} for {}", BufferUtil.toDetailString(buffer), _retainableByteBuffer, HttpConnection.this); - RetainableByteBuffer retainable = _retainableByteBuffer; - stream._chunk = Content.Chunk.from(buffer, false, new ChunkRetainable(retainable, buffer)); + _retainableByteBuffer.retain(); + stream._chunk = Content.Chunk.asChunk(buffer, false, _retainableByteBuffer); return true; } @@ -1109,26 +1106,6 @@ public void onComplianceViolation(ComplianceViolation.Mode mode, ComplianceViola } } - private class ChunkRetainable extends Retainable.Wrapper - { - private final ByteBuffer buffer; - - private ChunkRetainable(Retainable retainable, ByteBuffer buffer) - { - super(retainable); - this.buffer = buffer; - } - - @Override - public boolean release() - { - boolean released = super.release(); - if (LOG.isDebugEnabled()) - LOG.debug("content released {} {}/{} for {}", released, BufferUtil.toDetailString(buffer), getWrapped(), HttpConnection.this); - return released; - } - } - protected class HttpStreamOverHTTP1 implements HttpStream { private final long _nanoTime = NanoTime.now(); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index 241b8fc6268f..08753fcece9e 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -481,11 +481,12 @@ public boolean process(Request request, Response response, Callback callback) th { read += chunk.remaining(); chunk.getByteBuffer().clear(); - chunk.release(); if (!fourBytesRead.get() && read >= 4) fourBytesRead.set(true); } + chunk.release(); + if (chunk.isLast()) { callback.succeeded(); @@ -1708,6 +1709,8 @@ public void onClosed(Connection connection) if (chunk.hasRemaining()) contents.add(chunk); + else + chunk.release(); if (chunk.isLast()) break; diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java index 47badf3c8323..0cb04dead744 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java @@ -166,9 +166,10 @@ public boolean process(Request request, Response response, Callback callback) th int r = c.remaining(); c.get(content, offset, r); offset += r; - c.release(); } + c.release(); + if (c.isLast()) break; } diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockHttpStream.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockHttpStream.java index 69f63269280a..a2ccaf1f0042 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockHttpStream.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockHttpStream.java @@ -46,18 +46,6 @@ public boolean isLast() { return false; } - - @Override - public void retain() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean release() - { - return true; - } }; private final long _nanoTime = NanoTime.now(); private final AtomicReference _content = new AtomicReference<>(); @@ -98,8 +86,9 @@ public Runnable addContent(String content, boolean last) return addContent(BufferUtil.toBuffer(content), last); } - public Runnable addContent(Content.Chunk chunk) + private Runnable addContent(Content.Chunk chunk) { + chunk.retain(); chunk = _content.getAndSet(chunk); if (chunk == DEMAND) return _channel.onContentAvailable(); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index 4ffc33d7407a..d1f4ef717dfc 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -316,7 +316,8 @@ public void succeeded() }, t -> { - throw new IllegalStateException(); + chunk.release(); + throw new IllegalStateException(t); })); }); return true; diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DumpHandler.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DumpHandler.java index 9a74109357c3..e4136bcd9df0 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DumpHandler.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DumpHandler.java @@ -118,10 +118,11 @@ public boolean process(Request request, Response response, Callback callback) th if (!chunk.hasRemaining()) { + boolean last = chunk.isLast(); chunk.release(); - if (chunk.isLast()) - break; chunk = null; + if (last) + break; } } if (chunk != null) diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLReadEOFAfterResponseTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLReadEOFAfterResponseTest.java index 64ee9a1b1079..5411a40900f3 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLReadEOFAfterResponseTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLReadEOFAfterResponseTest.java @@ -95,10 +95,9 @@ public boolean process(Request request, Response response, Callback callback) th continue; } if (c.hasRemaining()) - { length -= c.remaining(); - c.release(); - } + c.release(); + // TODO: should not compare to EOF. if (c == Content.Chunk.EOF) callback.failed(new IllegalStateException()); } @@ -115,6 +114,7 @@ public boolean process(Request request, Response response, Callback callback) th // Third, read the EOF. Content.Chunk chunk = request.read(); + chunk.release(); if (!chunk.isLast()) throw new IllegalStateException(); callback.succeeded(); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java index 9d5256e7d2a3..448493c45bde 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java @@ -13,17 +13,19 @@ package org.eclipse.jetty.server.ssl; -import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.KeyStore; import java.util.Arrays; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManagerFactory; +import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; @@ -31,32 +33,35 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; -import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.toolchain.test.MavenPaths; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; public class SslUploadTest { - private static Server server; - private static ServerConnector connector; + private Server server; + private ServerConnector connector; + private Path keystoreFile; + private final String keystorePassword = "storepwd"; - @BeforeAll - public static void startServer() throws Exception + @BeforeEach + public void startServer() throws Exception { - File keystore = MavenTestingUtils.getTestResourceFile("keystore.p12"); + keystoreFile = MavenPaths.findTestResourceFile("keystore.p12"); SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); - sslContextFactory.setKeyStorePath(keystore.getAbsolutePath()); - sslContextFactory.setKeyStorePassword("storepwd"); + sslContextFactory.setKeyStorePath(keystoreFile.toString()); + sslContextFactory.setKeyStorePassword(keystorePassword); server = new Server(); connector = new ServerConnector(server, sslContextFactory); @@ -67,49 +72,57 @@ public static void startServer() throws Exception server.start(); } - @AfterAll - public static void stopServer() throws Exception + @AfterEach + public void stopServer() { - server.stop(); - server.join(); + LifeCycle.stop(server); } @Test - @Disabled - public void test() throws Exception + public void testUpload() throws Exception { KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); SslContextFactory ctx = connector.getConnectionFactory(SslConnectionFactory.class).getSslContextFactory(); - try (InputStream stream = new FileInputStream(ctx.getKeyStorePath())) + try (InputStream stream = Files.newInputStream(keystoreFile)) { - keystore.load(stream, "storepwd".toCharArray()); + keystore.load(stream, keystorePassword.toCharArray()); } TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keystore); SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustManagerFactory.getTrustManagers(), null); - SSLSocket socket = (SSLSocket)sslContext.getSocketFactory().createSocket("localhost", connector.getLocalPort()); - - OutputStream out = socket.getOutputStream(); - out.write("POST / HTTP/1.1\r\n".getBytes()); - out.write("Host: localhost\r\n".getBytes()); - out.write("Content-Length: 16777216\r\n".getBytes()); - out.write("Content-Type: bytes\r\n".getBytes()); - out.write("Connection: close\r\n".getBytes()); - out.write("\r\n".getBytes()); - out.flush(); - - byte[] requestContent = new byte[16777216]; - Arrays.fill(requestContent, (byte)120); - out.write(requestContent); - out.flush(); - - InputStream in = socket.getInputStream(); - String response = IO.toString(in); - assertTrue(response.indexOf("200") > 0); - - assertEquals(requestContent.length, 0); + try (SSLSocket socket = (SSLSocket)sslContext.getSocketFactory().createSocket("localhost", connector.getLocalPort())) + { + byte[] requestBody = new byte[16777216]; + Arrays.fill(requestBody, (byte)'x'); + + String rawRequest = """ + POST / HTTP/1.1\r + Host: localhost\r + Content-Length: %d\r + Content-Type: bytes\r + Connection: close\r + \r + """.formatted(requestBody.length); + + try (OutputStream out = socket.getOutputStream(); + InputStream in = socket.getInputStream()) + { + out.write(rawRequest.getBytes(StandardCharsets.UTF_8)); + out.flush(); + out.write(requestBody); + out.flush(); + + String rawResponse = IO.toString(in, StandardCharsets.UTF_8); + + HttpTester.Response response = HttpTester.parseResponse(rawResponse); + assertThat(response.getStatus(), is(200)); + + String responseBody = response.getContent(); + assertThat(responseBody, containsString("Read %d".formatted(requestBody.length))); + } + } } private static class EmptyHandler extends Handler.Abstract diff --git a/jetty-core/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-core/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java index 698dcbe43145..b29a927e8afd 100644 --- a/jetty-core/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java +++ b/jetty-core/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java @@ -24,9 +24,9 @@ import java.util.List; import java.util.stream.Collectors; +import org.eclipse.jetty.toolchain.test.MavenPaths; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -34,6 +34,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MainTest { @@ -142,12 +143,15 @@ public void testUnknownDistroCommand() throws Exception assertThat("JVM Arg on command line detail", warningIter.next(), containsString("Argument: --foople (interpreted as a JVM argument, from ")); } + /** + * A test to ensure that the usage text is still present and not accidentally deleted. + */ @Test - @Disabled("Just a bit noisy for general testing") - public void testHelp() throws Exception + public void testUsageHelpStillThere() throws Exception { - Main main = new Main(); - main.usage(false); + Path usageFile = MavenPaths.findMainResourceFile("org/eclipse/jetty/start/usage.txt"); + assertTrue(Files.exists(usageFile)); + assertTrue(Files.isRegularFile(usageFile)); } @Test diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AbstractTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AbstractTest.java index 8aa16bfeadb4..91889fcae2c4 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AbstractTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AbstractTest.java @@ -23,8 +23,8 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.fcgi.server.ServerFCGIConnectionFactory; import org.eclipse.jetty.http2.HTTP2Cipher; import org.eclipse.jetty.http2.client.HTTP2Client; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AsyncRequestContentTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AsyncRequestContentTest.java index 210bebda5a78..13f6edbaa043 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AsyncRequestContentTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AsyncRequestContentTest.java @@ -21,9 +21,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.InputStreamRequestContent; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.OutputStreamRequestContent; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ConnectionStatisticsTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ConnectionStatisticsTest.java index af36afe3197a..e53159b81c1e 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ConnectionStatisticsTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ConnectionStatisticsTest.java @@ -16,8 +16,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ForwardProxyWithDynamicTransportTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ForwardProxyWithDynamicTransportTest.java index c2412b941c5a..e1298b228a6e 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ForwardProxyWithDynamicTransportTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/ForwardProxyWithDynamicTransportTest.java @@ -25,14 +25,13 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.AbstractConnectionPool; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HostPortHttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpScheme; @@ -282,10 +281,10 @@ public boolean process(Request request, Response response, Callback callback) assertEquals(status, response2.getStatus()); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == serverPort) + .filter(d -> d.getOrigin().getAddress().getPort() == serverPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(1, connectionPool.getConnectionCount()); } @@ -317,10 +316,10 @@ public void testHTTP2TunnelClosedByClient() throws Exception Thread.sleep(2 * idleTimeout); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == serverPort) + .filter(d -> d.getOrigin().getAddress().getPort() == serverPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(0, connectionPool.getConnectionCount()); @@ -393,10 +392,10 @@ protected void handleConnect(Request request, Response response, Callback callba assertTrue(latch.await(5, TimeUnit.SECONDS)); List destinations = client.getDestinations().stream() - .filter(d -> d.getPort() == proxyPort) + .filter(d -> d.getOrigin().getAddress().getPort() == proxyPort) .toList(); assertEquals(1, destinations.size()); - HttpDestination destination = (HttpDestination)destinations.get(0); + Destination destination = destinations.get(0); AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool(); assertEquals(0, connectionPool.getConnectionCount()); } diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpChannelAssociationTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpChannelAssociationTest.java index ed7d5ab2f52a..d4faaafe8584 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpChannelAssociationTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpChannelAssociationTest.java @@ -18,19 +18,18 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpConnection; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpChannelOverHTTP; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.fcgi.client.http.HttpChannelOverFCGI; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; -import org.eclipse.jetty.fcgi.client.http.HttpConnectionOverFCGI; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.internal.HttpExchange; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.internal.HttpChannelOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.internal.HttpConnectionOverFCGI; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; @@ -149,14 +148,14 @@ public boolean associate(HttpExchange exchange) yield new HttpClientTransportOverHTTP2(http2Client) { @Override - protected HttpConnectionOverHTTP2 newHttpConnection(HttpDestination destination, Session session) + protected Connection newConnection(Destination destination, Session session) { return new HttpConnectionOverHTTP2(destination, session) { @Override protected HttpChannelOverHTTP2 newHttpChannel() { - return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession()) + return new HttpChannelOverHTTP2(this, getSession()) { @Override public boolean associate(HttpExchange exchange) @@ -178,14 +177,14 @@ public boolean associate(HttpExchange exchange) yield new HttpClientTransportOverHTTP3(http3Client) { @Override - protected HttpConnection newHttpConnection(HttpDestination destination, HTTP3SessionClient session) + protected org.eclipse.jetty.client.Connection newConnection(Destination destination, HTTP3SessionClient session) { return new HttpConnectionOverHTTP3(destination, session) { @Override protected HttpChannelOverHTTP3 newHttpChannel() { - return new HttpChannelOverHTTP3(getHttpDestination(), this, getSession()) + return new HttpChannelOverHTTP3(this, getSession()) { @Override public boolean associate(HttpExchange exchange) @@ -206,7 +205,7 @@ public boolean associate(HttpExchange exchange) yield new HttpClientTransportOverFCGI(clientConnector, "") { @Override - protected org.eclipse.jetty.io.Connection newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise promise) + protected org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Destination destination, Promise promise) { return new HttpConnectionOverFCGI(endPoint, destination, promise) { diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientConnectTimeoutTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientConnectTimeoutTest.java index b8bb0c68a692..0b63fffee89a 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientConnectTimeoutTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientConnectTimeoutTest.java @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.junit.jupiter.api.Tag; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientDemandTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientDemandTest.java index 48c65a938d31..83d3bd6433cb 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientDemandTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientDemandTest.java @@ -27,9 +27,9 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.zip.GZIPOutputStream; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpStatus; @@ -98,7 +98,6 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon @Override public void onContent(Response response, Content.Chunk chunk, Runnable demander) { - chunk.release(); if (chunks.incrementAndGet() == 1) contentLatch.countDown(); // Need to demand also after the second @@ -154,7 +153,8 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon @Override public void onContent(Response response, Content.Chunk chunk, Runnable demander) { - // Don't demand and don't release chunks. + // Store the chunk and don't demand. + chunk.retain(); contentQueue.offer(chunk); demanderQueue.offer(demander); } @@ -243,6 +243,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon client.newRequest(newURI(transport)) .onResponseContentAsync((response, chunk, demander) -> { + chunk.retain(); chunkRef.set(chunk); try { @@ -332,7 +333,6 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon { listener1Chunks.incrementAndGet(); listener1ContentSize.addAndGet(chunk.remaining()); - chunk.release(); listener1DemanderRef.set(demander); }; AtomicInteger listener2Chunks = new AtomicInteger(); @@ -342,7 +342,6 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon { listener2Chunks.incrementAndGet(); listener2ContentSize.addAndGet(chunk.remaining()); - chunk.release(); listener2DemanderRef.set(demander); }; @@ -414,9 +413,9 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon client.newRequest(newURI(transport)) .onResponseContentAsync((response, chunk, demander) -> { + boolean demand = chunk.hasRemaining(); received.put(chunk.getByteBuffer()); - chunk.release(); - if (!chunk.isTerminal()) + if (demand) new Thread(demander).start(); }) .send(result -> @@ -472,7 +471,7 @@ public void onContentSource(Response response, Content.Source contentSource) demander.run(); return; } - if (chunk.isTerminal()) + if (chunk.isLast() && !chunk.hasRemaining()) { chunk.release(); return; @@ -533,7 +532,7 @@ public void onContentSource(Response response, Content.Source contentSource) demander.run(); return; } - if (chunk.isTerminal()) + if (chunk.isLast() && !chunk.hasRemaining()) { chunk.release(); return; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientIdleTimeoutTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientIdleTimeoutTest.java index 19a9c1bf433c..cabb17f7b1ae 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientIdleTimeoutTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientIdleTimeoutTest.java @@ -16,7 +16,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientLoadTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientLoadTest.java index 33a76835467f..22250afa4a1a 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientLoadTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientLoadTest.java @@ -25,12 +25,12 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.stream.IntStream; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.Connection; import org.eclipse.jetty.client.LeakTrackingConnectionPool; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; @@ -66,10 +66,6 @@ public class HttpClientLoadTest extends AbstractTest @MethodSource("transports") public void testIterative(Transport transport) throws Exception { - // TODO: cannot run HTTP/3 (or UDP) in Jenkins. - if ("ci".equals(System.getProperty("env"))) - Assumptions.assumeTrue(transport != Transport.H3); - server = newServer(); server.addBean(new LeakTrackingByteBufferPool(new LogarithmicArrayByteBufferPool())); start(transport, new LoadHandler()); @@ -84,7 +80,7 @@ public void testIterative(Transport transport) throws Exception case HTTP, HTTPS, FCGI, UNIX_DOMAIN -> { // Track connection leaking only for non-multiplexed transports. - client.getTransport().setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination) + client.getTransport().setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination()) { @Override protected void leaked(LeakDetector.LeakInfo leakInfo) @@ -132,8 +128,8 @@ public void testConcurrent(Transport transport) throws Exception int runs = 1; int iterations = 128; IntStream.range(0, 16).parallel().forEach(i -> - IntStream.range(0, runs).forEach(j -> - run(transport, iterations))); + IntStream.range(0, runs).forEach(j -> + run(transport, iterations))); assertLeaks(); } diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java index 5816bb7d1e86..1c5394c8a21d 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java @@ -36,15 +36,15 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.OutputStreamRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.Content; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTest.java index 94b0b5dec165..a8e6156fe13a 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTest.java @@ -30,15 +30,14 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; -import org.eclipse.jetty.client.HttpDestination; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.FutureResponseListener; +import org.eclipse.jetty.client.InputStreamResponseListener; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -131,7 +130,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon } }); - org.eclipse.jetty.client.api.Request request = client.newRequest(newURI(transport)); + org.eclipse.jetty.client.Request request = client.newRequest(newURI(transport)); FutureResponseListener listener = new FutureResponseListener(request, length); request.timeout(10, TimeUnit.SECONDS).send(listener); ContentResponse response = listener.get(); @@ -175,7 +174,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon } }); - org.eclipse.jetty.client.api.Request request = client.newRequest(newURI(transport)); + org.eclipse.jetty.client.Request request = client.newRequest(newURI(transport)); FutureResponseListener listener = new FutureResponseListener(request, 2 * length); request.timeout(10, TimeUnit.SECONDS).send(listener); ContentResponse response = listener.get(); @@ -306,7 +305,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon }); // Make a request with a large enough response buffer. - org.eclipse.jetty.client.api.Request request = client.newRequest(newURI(transport)); + org.eclipse.jetty.client.Request request = client.newRequest(newURI(transport)); FutureResponseListener listener = new FutureResponseListener(request, length); request.send(listener); ContentResponse response = listener.get(15, TimeUnit.SECONDS); @@ -517,7 +516,6 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon client.newRequest(newURI(transport)) .onResponseContentAsync((response, chunk, demander) -> { - chunk.release(); if (counter.incrementAndGet() == 1) { demanderRef.set(demander); @@ -643,7 +641,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon } }); - org.eclipse.jetty.client.api.Request request = client.newRequest(newURI(transport)) + org.eclipse.jetty.client.Request request = client.newRequest(newURI(transport)) .method(HttpMethod.HEAD); FutureResponseListener listener = new FutureResponseListener(request, length / 2); request.send(listener); @@ -757,7 +755,7 @@ public boolean process(Request request, org.eclipse.jetty.server.Response respon httpConfig.getCustomizer(SecureRequestCustomizer.class).setSniHostCheck(false); Origin origin = new Origin(requestScheme, "localhost", ((NetworkConnector)connector).getLocalPort()); - HttpDestination destination = client.resolveDestination(origin); + Destination destination = client.resolveDestination(origin); var request = client.newRequest(requestHost, requestPort) .scheme(requestScheme) @@ -828,7 +826,7 @@ public void testContentSourceListeners(Transport transport) throws Exception @Override public void onContentSource(Response response, Content.Source contentSource) { - accumulateChunks(response, contentSource, chunks); + accumulateChunks(contentSource, chunks); } }; client.newRequest(newURI(transport)) @@ -878,7 +876,7 @@ public void testContentSourceListenerDemandInSpawnedThread(Transport transport) @Override public void onContentSource(Response response, Content.Source contentSource) { - new Thread(() -> accumulateChunksInSpawnedThread(response, contentSource, chunks)) + new Thread(() -> accumulateChunksInSpawnedThread(contentSource, chunks)) .start(); } }; @@ -905,9 +903,9 @@ public void testParallelContentSourceListeners(Transport transport) throws Excep ContentResponse resp = client.newRequest(newURI(transport)) .path("/") - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks1)) - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks2)) - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks3)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks1)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks2)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks3)) .send(); assertThat(resp.getStatus(), is(200)); @@ -933,8 +931,8 @@ public void testParallelContentSourceListenersPartialFailure(Transport transport List chunks3 = new CopyOnWriteArrayList<>(); ContentResponse contentResponse = client.newRequest(newURI(transport)) .path("/") - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks1)) - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks2)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks1)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks2)) .onResponseContentSource((response, contentSource) -> { contentSource.fail(new Exception("Synthetic Failure")); @@ -949,6 +947,10 @@ public void testParallelContentSourceListenersPartialFailure(Transport transport assertThat(chunks3.stream().mapToInt(c -> c.getByteBuffer().remaining()).sum(), is(0)); assertThat(chunks3.size(), is(1)); assertThat(chunks3.get(0), instanceOf(Content.Chunk.Error.class)); + + chunks1.forEach(Content.Chunk::release); + chunks2.forEach(Content.Chunk::release); + chunks3.forEach(Content.Chunk::release); } @ParameterizedTest @@ -964,8 +966,8 @@ public void testParallelContentSourceListenersPartialFailureInSpawnedThread(Tran CountDownLatch chunks3Latch = new CountDownLatch(1); ContentResponse contentResponse = client.newRequest(newURI(transport)) .path("/") - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks1)) - .onResponseContentSource((response, contentSource) -> accumulateChunks(response, contentSource, chunks2)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks1)) + .onResponseContentSource((response, contentSource) -> accumulateChunks(contentSource, chunks2)) .onResponseContentSource((response, contentSource) -> new Thread(() -> { @@ -987,6 +989,10 @@ public void testParallelContentSourceListenersPartialFailureInSpawnedThread(Tran assertThat(chunks3.stream().mapToInt(c -> c.getByteBuffer().remaining()).sum(), is(0)); assertThat(chunks3.size(), is(1)); assertThat(chunks3.get(0), instanceOf(Content.Chunk.Error.class)); + + chunks1.forEach(Content.Chunk::release); + chunks2.forEach(Content.Chunk::release); + chunks3.forEach(Content.Chunk::release); } @ParameterizedTest @@ -1026,47 +1032,52 @@ private static void sleep(long time) throws IOException } } - private static void accumulateChunks(Response response, Content.Source contentSource, List chunks) + private static void accumulateChunks(Content.Source contentSource, List chunks) { Content.Chunk chunk = contentSource.read(); if (chunk == null) { - contentSource.demand(() -> accumulateChunks(response, contentSource, chunks)); + contentSource.demand(() -> accumulateChunks(contentSource, chunks)); return; } - chunks.add(duplicateAndRelease(chunk)); + chunks.add(duplicate(chunk)); + chunk.release(); if (!chunk.isLast()) - contentSource.demand(() -> accumulateChunks(response, contentSource, chunks)); + contentSource.demand(() -> accumulateChunks(contentSource, chunks)); } - private static void accumulateChunksInSpawnedThread(Response response, Content.Source contentSource, List chunks) + private static void accumulateChunksInSpawnedThread(Content.Source contentSource, List chunks) { Content.Chunk chunk = contentSource.read(); if (chunk == null) { - contentSource.demand(() -> new Thread(() -> accumulateChunks(response, contentSource, chunks)).start()); + contentSource.demand(() -> new Thread(() -> accumulateChunks(contentSource, chunks)).start()); return; } - chunks.add(duplicateAndRelease(chunk)); + chunks.add(duplicate(chunk)); + chunk.release(); if (!chunk.isLast()) - contentSource.demand(() -> new Thread(() -> accumulateChunks(response, contentSource, chunks)).start()); + contentSource.demand(() -> new Thread(() -> accumulateChunks(contentSource, chunks)).start()); } - private static Content.Chunk duplicateAndRelease(Content.Chunk chunk) + private static Content.Chunk duplicate(Content.Chunk chunk) { - if (chunk == null || chunk.isTerminal()) - return chunk; - - ByteBuffer buffer = BufferUtil.allocate(chunk.remaining()); - int pos = BufferUtil.flipToFill(buffer); - buffer.put(chunk.getByteBuffer()); - BufferUtil.flipToFlush(buffer, pos); - chunk.release(); - return Content.Chunk.from(buffer, chunk.isLast()); + if (chunk.hasRemaining()) + { + ByteBuffer byteBuffer = BufferUtil.allocate(chunk.remaining()); + int pos = BufferUtil.flipToFill(byteBuffer); + byteBuffer.put(chunk.getByteBuffer()); + BufferUtil.flipToFlush(byteBuffer, pos); + return Content.Chunk.from(byteBuffer, chunk.isLast()); + } + else + { + return chunk.isLast() ? Content.Chunk.EOF : Content.Chunk.EMPTY; + } } private static class TestProcessor extends Handler.Abstract diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTimeoutTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTimeoutTest.java index e91c1d5f8c5f..5d56a172565c 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTimeoutTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTimeoutTest.java @@ -25,15 +25,15 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.net.ssl.SSLEngine; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.InputStreamRequestContent; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ClientConnectionFactory; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTransportDynamicTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTransportDynamicTest.java index 09b08c202085..755e4f5e0446 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTransportDynamicTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientTransportDynamicTest.java @@ -23,18 +23,16 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.AbstractConnectionPool; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpScheme; @@ -271,7 +269,7 @@ private void testProtocolSelection(HttpScheme scheme) throws Exception HttpClientTransportDynamic transport = new HttpClientTransportDynamic(clientConnector, h1, http2) { @Override - public Origin newOrigin(HttpRequest request) + public Origin newOrigin(org.eclipse.jetty.client.Request request) { // Use prior-knowledge, i.e. negotiate==false. boolean secure = HttpClient.isSchemeSecure(request.getScheme()); @@ -302,8 +300,7 @@ public Origin newOrigin(HttpRequest request) List destinations = client.getDestinations(); assertEquals(2, destinations.size()); assertEquals(1, destinations.stream() - .map(HttpDestination.class::cast) - .map(HttpDestination::getOrigin) + .map(Destination::getOrigin) .map(Origin::asString) .distinct() .count()); @@ -337,8 +334,7 @@ public void testEncryptedProtocolSelectionWithNegotiation() throws Exception List destinations = client.getDestinations(); assertEquals(2, destinations.size()); assertEquals(1, destinations.stream() - .map(HttpDestination.class::cast) - .map(HttpDestination::getOrigin) + .map(Destination::getOrigin) .map(Origin::asString) .distinct() .count()); @@ -409,7 +405,7 @@ public boolean process(Request request, Response response, Callback callback) startClient(HttpClientConnectionFactory.HTTP11); // Simulate a proxy request to the server. - HttpRequest proxyRequest1 = (HttpRequest)client.newRequest("localhost", connector.getLocalPort()); + var proxyRequest1 = client.newRequest("localhost", connector.getLocalPort()); // Map the proxy request to client IP:port. int clientPort1 = ThreadLocalRandom.current().nextInt(1024, 65536); proxyRequest1.tag(new V1.Tag("localhost", clientPort1)); @@ -419,7 +415,7 @@ public boolean process(Request request, Response response, Callback callback) assertEquals(String.valueOf(clientPort1), proxyResponse1.getContentAsString()); // Simulate another request to the server, from a different client port. - HttpRequest proxyRequest2 = (HttpRequest)client.newRequest("localhost", connector.getLocalPort()); + var proxyRequest2 = client.newRequest("localhost", connector.getLocalPort()); int clientPort2 = ThreadLocalRandom.current().nextInt(1024, 65536); proxyRequest2.tag(new V1.Tag("localhost", clientPort2)); ContentResponse proxyResponse2 = proxyRequest2 @@ -431,8 +427,7 @@ public boolean process(Request request, Response response, Callback callback) List destinations = client.getDestinations(); assertEquals(2, destinations.size()); assertEquals(1, destinations.stream() - .map(HttpDestination.class::cast) - .map(HttpDestination::getOrigin) + .map(Destination::getOrigin) .map(Origin::asString) .distinct() .count()); @@ -483,8 +478,7 @@ public void testClearTextAndEncryptedHTTP2() throws Exception List destinations = client.getDestinations(); assertEquals(4, destinations.size()); assertEquals(2, destinations.stream() - .map(HttpDestination.class::cast) - .map(HttpDestination::getOrigin) + .map(Destination::getOrigin) .map(Origin::asString) .distinct() .count()); @@ -523,11 +517,11 @@ public boolean process(Request request, Response response, Callback callback) // We must have 2 different destinations with the same origin. List destinations = client.getDestinations(); assertEquals(2, destinations.size()); - HttpDestination h1Destination = (HttpDestination)destinations.get(0); - HttpDestination h2Destination = (HttpDestination)destinations.get(1); + Destination h1Destination = destinations.get(0); + Destination h2Destination = destinations.get(1); if (h2Destination.getOrigin().getProtocol().getProtocols().contains("http/1.1")) { - HttpDestination swap = h1Destination; + Destination swap = h1Destination; h1Destination = h2Destination; h2Destination = swap; } diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpInterimResponseTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpInterimResponseTest.java index 19dbaf1a6a5b..28f4039aec77 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpInterimResponseTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpInterimResponseTest.java @@ -16,8 +16,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/RoundRobinConnectionPoolTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/RoundRobinConnectionPoolTest.java index 9c7f7741458e..af4cf89a6c72 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/RoundRobinConnectionPoolTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/RoundRobinConnectionPoolTest.java @@ -26,8 +26,8 @@ import java.util.function.Function; import java.util.stream.Collectors; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.RoundRobinConnectionPool; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.quic.server.QuicServerConnector; import org.eclipse.jetty.server.Handler; @@ -67,7 +67,7 @@ public boolean process(Request request, Response response, Callback callback) CompletableFuture setup = new CompletableFuture<>(); client.getTransport().setConnectionPoolFactory(destination -> { - RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, destination); + RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections); pool.preCreateConnections(maxConnections).handle((r, x) -> x != null ? setup.completeExceptionally(x) : setup.complete(null)); return pool; }); @@ -146,7 +146,7 @@ public boolean process(Request request, Response response, Callback callback) CompletableFuture setup = new CompletableFuture<>(); client.getTransport().setConnectionPoolFactory(destination -> { - RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, destination); + RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections); pool.preCreateConnections(maxConnections).handle((r, x) -> x != null ? setup.completeExceptionally(x) : setup.complete(null)); return pool; }); @@ -225,7 +225,7 @@ public boolean process(Request request, Response response, Callback callback) ((QuicServerConnector)connector).getQuicConfiguration().setMaxBidirectionalRemoteStreams(maxUsage); client.getTransport().setConnectionPoolFactory(destination -> { - RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, destination, maxMultiplex); + RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, maxMultiplex); pool.setMaxUsage(maxUsage); return pool; }); diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/TrailersTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/TrailersTest.java index 5c9c7135da21..a99046c57df9 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/TrailersTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/TrailersTest.java @@ -18,8 +18,8 @@ import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.OutputStreamRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Handler; diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/VirtualThreadsTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/VirtualThreadsTest.java index 76c822b191db..9769b3b52ab6 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/VirtualThreadsTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/VirtualThreadsTest.java @@ -19,7 +19,7 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; diff --git a/jetty-core/jetty-unixdomain-server/src/test/java/org/eclipse/jetty/unixdomain/server/UnixDomainTest.java b/jetty-core/jetty-unixdomain-server/src/test/java/org/eclipse/jetty/unixdomain/server/UnixDomainTest.java index 91de6da67d5f..46657c5c58d5 100644 --- a/jetty-core/jetty-unixdomain-server/src/test/java/org/eclipse/jetty/unixdomain/server/UnixDomainTest.java +++ b/jetty-core/jetty-unixdomain-server/src/test/java/org/eclipse/jetty/unixdomain/server/UnixDomainTest.java @@ -19,10 +19,10 @@ import java.nio.file.Path; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-core/jetty-util/pom.xml b/jetty-core/jetty-util/pom.xml index 24e2ef48da9b..ced2ad214a01 100644 --- a/jetty-core/jetty-util/pom.xml +++ b/jetty-core/jetty-util/pom.xml @@ -70,6 +70,12 @@ org.slf4j slf4j-api + + com.google.jimfs + jimfs + 1.2 + test + org.awaitility awaitility diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java index 88cecb426dfa..a7fc6c328501 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java @@ -49,12 +49,6 @@ public final class URIUtil { private static final Logger LOG = LoggerFactory.getLogger(URIUtil.class); - private static final Index KNOWN_SCHEMES = new Index.Builder() - .caseSensitive(false) - .with("file:") - .with("jrt:") - .with("jar:") - .build(); // From https://www.rfc-editor.org/rfc/rfc3986 private static final String UNRESERVED = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-._~"; diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceFactoryInternals.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceFactoryInternals.java index 5f3406e24cd1..d810e1853d61 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceFactoryInternals.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceFactoryInternals.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.Path; import java.nio.file.ProviderNotFoundException; import java.util.List; @@ -48,10 +49,23 @@ class ResourceFactoryInternals CURRENT_WORKING_DIR = Path.of(System.getProperty("user.dir")); // The default resource factories - RESOURCE_FACTORIES.put("jar", new MountedPathResourceFactory()); + MountedPathResourceFactory mountedPathResourceFactory = new MountedPathResourceFactory(); + RESOURCE_FACTORIES.put("jar", mountedPathResourceFactory); PathResourceFactory pathResourceFactory = new PathResourceFactory(); RESOURCE_FACTORIES.put("file", pathResourceFactory); RESOURCE_FACTORIES.put("jrt", pathResourceFactory); + + /* Best effort attempt to detect that an alternate FileSystem type that is in use. + * We don't attempt to look up a Class, as not all runtimes and environments have the classes anymore + * (eg: they were compiled into native code) + * The build.properties is present in the jetty-util jar, so it's reasonably safe to look for that + * as a resource + */ + URL url = ResourceFactoryInternals.class.getResource("/org/eclipse/jetty/version/build.properties"); + if ((url != null) && !RESOURCE_FACTORIES.contains(url.getProtocol())) + { + RESOURCE_FACTORIES.put(url.getProtocol(), mountedPathResourceFactory); + } } static ResourceFactory ROOT = new CompositeResourceFactory() diff --git a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/AlternateFileSystemResourceTest.java b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/AlternateFileSystemResourceTest.java new file mode 100644 index 000000000000..90594b456ca0 --- /dev/null +++ b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/AlternateFileSystemResourceTest.java @@ -0,0 +1,123 @@ +// +// ======================================================================== +// 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.util.resource; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.Files; +import java.util.Optional; + +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Jimfs; +import org.eclipse.jetty.util.IO; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Test to ensure that Alternate FileSystem providers work as expected. + * + *

+ * Uses the google/jimfs In-Memory FileSystem provider + * to have a FileSystem based on scheme `jimfs` (with an authority) + *

+ */ +public class AlternateFileSystemResourceTest +{ + private static final Logger LOG = LoggerFactory.getLogger(AlternateFileSystemResourceTest.class); + private FileSystem jimfs; + private URI fsBaseURI; + + @BeforeEach + public void initInMemoryFileSystem(TestInfo testInfo) + { + Optional testMethod = testInfo.getTestMethod(); + if (testMethod.isPresent()) + { + String testMethodName = testMethod.get().getName(); + // Create a jimfs that has the testMethodName as its authority + // eg: jimfs:/// + jimfs = Jimfs.newFileSystem(testMethodName, Configuration.unix()); + } + else + { + // Let jimfs establish a unique name on its own + // eg: jimfs://a3cc0bda-1238-4847-864f-22fae7614146/ + jimfs = Jimfs.newFileSystem(Configuration.unix()); + } + fsBaseURI = jimfs.getPath("/").toUri(); + + ResourceFactory.registerResourceFactory(fsBaseURI.getScheme(), new MountedPathResourceFactory()); + } + + @AfterEach + public void closeInMemoryFileSystem() + { + IO.close(jimfs); + } + + @Test + public void testNewResource() throws IOException + { + // Create some content to reference + Files.writeString(jimfs.getPath("/foo.txt"), "Hello Foo", StandardCharsets.UTF_8); + + // Reference it via Resource object + Resource resource = ResourceFactory.root().newResource(fsBaseURI.resolve("/foo.txt")); + assertTrue(Resources.isReadable(resource)); + + LOG.info("resource = {}", resource); + + try (InputStream in = resource.newInputStream()) + { + String contents = IO.toString(in, StandardCharsets.UTF_8); + assertThat(contents, is("Hello Foo")); + } + } + + @Test + public void testNavigateResource() throws IOException + { + // Create some content to reference + Files.createDirectories(jimfs.getPath("/zed")); + Files.writeString(jimfs.getPath("/zed/bar.txt"), "Hello Bar", StandardCharsets.UTF_8); + + // Reference it via Resource object + Resource resourceRoot = ResourceFactory.root().newResource(fsBaseURI.resolve("/")); + assertTrue(Resources.isDirectory(resourceRoot)); + + Resource resourceZedDir = resourceRoot.resolve("zed"); + assertTrue(Resources.isDirectory(resourceZedDir)); + + Resource resourceBarText = resourceZedDir.resolve("bar.txt"); + LOG.info("resource = {}", resourceBarText); + + try (InputStream in = resourceBarText.newInputStream()) + { + String contents = IO.toString(in, StandardCharsets.UTF_8); + assertThat(contents, is("Hello Bar")); + } + } +} diff --git a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceFactoryTest.java b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceFactoryTest.java index aa8dc944deba..8b772b191cc1 100644 --- a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceFactoryTest.java +++ b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceFactoryTest.java @@ -13,9 +13,14 @@ package org.eclipse.jetty.util.resource; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URI; +import java.net.URL; import java.nio.file.Path; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -62,8 +67,22 @@ public void testCustomUriSchemeRegistered() } @Test - public void testRegisterHttpsUrlFactory() + public void testRegisterHttpsUrlFactory() throws MalformedURLException { + URI uri = URI.create("https://webtide.com/"); + + // Verify that environment can access the URI. + URL url = uri.toURL(); + try + { + HttpURLConnection http = (HttpURLConnection)url.openConnection(); + Assumptions.assumeTrue(http.getResponseCode() == HttpURLConnection.HTTP_OK); + } + catch (IOException e) + { + Assumptions.abort("Unable to connect to " + uri); + } + ResourceFactory.registerResourceFactory("https", new URLResourceFactory()); // Try as a normal String input Resource resource = ResourceFactory.root().newResource("https://webtide.com/"); @@ -71,7 +90,6 @@ public void testRegisterHttpsUrlFactory() assertThat(resource.getName(), is("https://webtide.com/")); // Try as a formal URI object as input - URI uri = URI.create("https://webtide.com/"); resource = ResourceFactory.root().newResource(uri); assertThat(resource.getURI(), is(URI.create("https://webtide.com/"))); assertThat(resource.getName(), is("https://webtide.com/")); diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java index 5515c7ef8c0c..cc681f3878a5 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java @@ -14,6 +14,7 @@ package org.eclipse.jetty.websocket.core.client; import java.io.IOException; +import java.net.HttpCookie; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -21,18 +22,17 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.stream.Collectors; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpConversation; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpUpgrader; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpStatus; @@ -61,7 +61,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class CoreClientUpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpUpgrader.Factory +public abstract class CoreClientUpgradeRequest implements Response.CompleteListener, HttpUpgrader.Factory { public static CoreClientUpgradeRequest from(WebSocketCoreClient webSocketClient, URI requestURI, FrameHandler frameHandler) { @@ -76,7 +76,9 @@ public FrameHandler getFrameHandler() } private static final Logger LOG = LoggerFactory.getLogger(CoreClientUpgradeRequest.class); - protected final CompletableFuture futureCoreSession; + + private final Request request; + private final CompletableFuture futureCoreSession; private final WebSocketCoreClient wsClient; private FrameHandler frameHandler; private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); @@ -85,7 +87,8 @@ public FrameHandler getFrameHandler() public CoreClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI) { - super(webSocketClient.getHttpClient(), new HttpConversation(), requestURI); + request = webSocketClient.getHttpClient().newRequest(requestURI); + request.attribute(HttpUpgrader.Factory.class.getName(), this); // Validate websocket URI if (!requestURI.isAbsolute()) @@ -106,10 +109,50 @@ public CoreClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI request this.futureCoreSession.whenComplete((session, throwable) -> { if (throwable != null) - abort(throwable); + request.abort(throwable); }); } + public String getMethod() + { + return request.getMethod(); + } + + public URI getURI() + { + return request.getURI(); + } + + public HttpVersion getVersion() + { + return request.getVersion(); + } + + public void listener(Request.Listener listener) + { + request.listener(listener); + } + + public void headers(Consumer consumer) + { + request.headers(consumer); + } + + public HttpFields getHeaders() + { + return request.getHeaders(); + } + + public List getCookies() + { + return request.getCookies(); + } + + public void timeout(long value, TimeUnit unit) + { + request.timeout(value, unit); + } + public void setConfiguration(Configuration.ConfigurationCustomizer config) { config.customize(customizer); @@ -145,12 +188,12 @@ public void setExtensions(List configs) public List getSubProtocols() { - return getHeaders().getCSV(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, true); + return request.getHeaders().getCSV(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL, true); } public void setSubProtocols(String... protocols) { - headers(headers -> + request.headers(headers -> { headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL); for (String protocol : protocols) @@ -162,7 +205,7 @@ public void setSubProtocols(String... protocols) public void setSubProtocols(List protocols) { - headers(headers -> + request.headers(headers -> { headers.remove(HttpHeader.SEC_WEBSOCKET_SUBPROTOCOL); for (String protocol : protocols) @@ -172,8 +215,7 @@ public void setSubProtocols(List protocols) }); } - @Override - public void send(final Response.CompleteListener listener) + public void send(Response.CompleteListener listener) { try { @@ -186,7 +228,7 @@ public void send(final Response.CompleteListener listener) throw new IllegalArgumentException("FrameHandler could not be created", t); } - super.send(listener); + request.send(listener); } public CompletableFuture sendAsync() @@ -282,23 +324,23 @@ public void requestComplete() .collect(Collectors.joining(",")); if (!StringUtil.isEmpty(extensionString)) - headers(headers -> headers.add(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, extensionString)); + request.headers(headers -> headers.add(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, extensionString)); // Notify the listener which may change the headers directly. - Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeRequest(this)); + Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeRequest(request)); if (listenerError != null) { - abort(listenerError); + request.abort(listenerError); return; } // Check if extensions were set in the headers from the upgrade listener. - String extsAfterListener = String.join(",", getHeaders().getCSV(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, true)); + String extsAfterListener = String.join(",", request.getHeaders().getCSV(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, true)); if (!extensionString.equals(extsAfterListener)) { // If extensions were set in both the ClientUpgradeRequest and UpgradeListener throw ISE. if (!requestedExtensions.isEmpty()) - abort(new IllegalStateException("Extensions set in both the ClientUpgradeRequest and UpgradeListener")); + request.abort(new IllegalStateException("Extensions set in both the ClientUpgradeRequest and UpgradeListener")); // Otherwise reparse the new set of requested extensions. requestedExtensions = ExtensionConfig.parseList(extsAfterListener); @@ -324,7 +366,7 @@ private Throwable notifyUpgradeListeners(Consumer action) return multiException; } - public void upgrade(HttpResponse response, EndPoint endPoint) + public void upgrade(Response response, EndPoint endPoint) { // Parse the Negotiated Extensions List negotiatedExtensions = new ArrayList<>(); @@ -424,7 +466,6 @@ else if (values.length == 1) // We can upgrade customize(endPoint); - Request request = response.getRequest(); Negotiated negotiated = new Negotiated( request.getURI(), negotiatedSubProtocol, @@ -442,7 +483,7 @@ else if (values.length == 1) WebSocketConnection wsConnection = new WebSocketConnection(endPoint, httpClient.getExecutor(), httpClient.getScheduler(), bufferPool, retainableByteBufferPool, coreSession); wsClient.getEventListeners().forEach(wsConnection::addEventListener); coreSession.setWebSocketConnection(wsConnection); - Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(this, response)); + Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(request, response)); if (listenerError != null) throw new WebSocketException("onHandshakeResponse error", listenerError); @@ -451,7 +492,7 @@ else if (values.length == 1) { endPoint.upgrade(wsConnection); - // Try to complete the future but if we could't we should abort the CoreSession + // Try to complete the future but if we could not, abort the CoreSession. if (!futureCoreSession.complete(coreSession)) { futureCoreSession.exceptionally(t -> diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java index be07664643b6..f7ac1d641f0f 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java @@ -13,8 +13,8 @@ package org.eclipse.jetty.websocket.core.client; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; public interface UpgradeListener { @@ -23,7 +23,7 @@ public interface UpgradeListener * * @param request the request */ - default void onHandshakeRequest(HttpRequest request) + default void onHandshakeRequest(Request request) { } @@ -33,7 +33,7 @@ default void onHandshakeRequest(HttpRequest request) * @param request the request that was used * @param response the response that was received */ - default void onHandshakeResponse(HttpRequest request, HttpResponse response) + default void onHandshakeResponse(Request request, Response response) { } } diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index d29ee0ba4c7c..d2eb345ba8fd 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -19,7 +19,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.websocket.core.CoreSession; diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java index 8e78eb856b3a..5b94af165b8f 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java @@ -17,10 +17,10 @@ import java.util.Base64; import java.util.concurrent.ThreadLocalRandom; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpResponseException; import org.eclipse.jetty.client.HttpUpgrader; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; @@ -47,7 +47,7 @@ public HttpUpgraderOverHTTP(CoreClientUpgradeRequest clientUpgradeRequest) } @Override - public void prepare(HttpRequest request) + public void prepare(Request request) { request.method(HttpMethod.GET).version(HttpVersion.HTTP_1_1) .headers(headers -> headers @@ -74,9 +74,9 @@ private String generateRandomKey() } @Override - public void upgrade(HttpResponse response, EndPoint endPoint, Callback callback) + public void upgrade(Response response, EndPoint endPoint, Callback callback) { - HttpRequest request = (HttpRequest)response.getRequest(); + Request request = response.getRequest(); HttpFields requestHeaders = request.getHeaders(); if (requestHeaders.contains(HttpHeader.UPGRADE, "websocket")) { diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java index 19300bb4fdb3..2f0b30d2c839 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java @@ -13,9 +13,9 @@ package org.eclipse.jetty.websocket.core.client.internal; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpUpgrader; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.PreEncodedHttpField; @@ -35,9 +35,9 @@ public HttpUpgraderOverHTTP2(CoreClientUpgradeRequest clientUpgradeRequest) } @Override - public void prepare(HttpRequest request) + public void prepare(Request request) { - request.upgradeProtocol("websocket") + request.attribute(HttpUpgrader.PROTOCOL_ATTRIBUTE, "websocket") .method(HttpMethod.CONNECT) .headers(headers -> headers.put(WS_VERSION_FIELD)); @@ -46,7 +46,7 @@ public void prepare(HttpRequest request) } @Override - public void upgrade(HttpResponse response, EndPoint endPoint, Callback callback) + public void upgrade(Response response, EndPoint endPoint, Callback callback) { try { diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/UpgradeWithLeftOverHttpBytesTest.java b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/UpgradeWithLeftOverHttpBytesTest.java index 6b10c5bef0a8..4b514462be4d 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/UpgradeWithLeftOverHttpBytesTest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/UpgradeWithLeftOverHttpBytesTest.java @@ -27,7 +27,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.StringUtil; diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java index eda439736642..e9d495832a13 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.logging.StacklessLogging; @@ -149,7 +149,7 @@ public void testExtensionSelection() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } @@ -180,7 +180,7 @@ public void testNotOfferedParameter() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } @@ -226,7 +226,7 @@ public void testNotAcceptingExtensions() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } @@ -274,7 +274,7 @@ public void testAcceptTwoExtensionsOfSameName() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } @@ -318,7 +318,7 @@ public void testNoSubProtocolSelected() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { headers.complete(response.getHeaders()); } @@ -380,13 +380,13 @@ public void testListenerExtensionSelection() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { request.headers(headers -> headers.put(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, "permessage-deflate")); } @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } @@ -411,7 +411,7 @@ public void testListenerExtensionSelectionError() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { request.headers(headers -> headers.put(HttpHeader.SEC_WEBSOCKET_EXTENSIONS, "permessage-deflate")); } @@ -469,7 +469,7 @@ public void testClientRequestedInternalExtensions(String reqExts, String negExts upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { extensionHeader.complete(response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS)); } diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java index a48ed1882f44..6f8a4f26ea89 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java @@ -198,7 +198,7 @@ public Future upgrade(MessageHandler handler, URI uri) throws Excep { // We manually set the port as we run the server in docker container. CoreClientUpgradeRequest upgradeRequest = CoreClientUpgradeRequest.from(client, uri, handler); - upgradeRequest.addHeader(new HttpField(HttpHeader.HOST, "localhost:9001")); + upgradeRequest.headers(headers -> headers.put(new HttpField(HttpHeader.HOST, "localhost:9001"))); return client.connect(upgradeRequest); } diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java index 12c31df9e6ca..b552da9a9603 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java @@ -19,8 +19,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.util.BufferUtil; @@ -109,7 +109,7 @@ public void testClientDeflateBufferSize() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { futureRequestHeaders.complete(request.getHeaders()); } @@ -163,7 +163,7 @@ public void testClientInflateBufferSize() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { futureRequestHeaders.complete(request.getHeaders()); } @@ -218,7 +218,7 @@ public void testServerDeflateBufferSize() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { futureResponseHeaders.complete(request.getHeaders()); } @@ -273,7 +273,7 @@ public void testServerInflateBufferSize() throws Exception upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { futureResponseHeaders.complete(request.getHeaders()); } diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-async-rest/jetty-ee10-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee10/demos/AsyncRestServlet.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-async-rest/jetty-ee10-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee10/demos/AsyncRestServlet.java index 2cc49a7b38a9..c753545ec041 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-async-rest/jetty-ee10-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee10/demos/AsyncRestServlet.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-async-rest/jetty-ee10-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee10/demos/AsyncRestServlet.java @@ -27,8 +27,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.NanoTime; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/AbstractEmbeddedTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/AbstractEmbeddedTest.java index cfa09bb58b08..4dc4565b6e81 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/AbstractEmbeddedTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/AbstractEmbeddedTest.java @@ -13,9 +13,9 @@ package org.eclipse.jetty.ee10.demos; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerTest.java index 26968077546f..b44e0f2ea80a 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerTest.java @@ -15,8 +15,8 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerXmlTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerXmlTest.java index 23c10f7b71f0..8d2554c2b3df 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerXmlTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ExampleServerXmlTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FastFileServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FastFileServerTest.java index 4839ef9fcdb0..b0b6f379286e 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FastFileServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FastFileServerTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerTest.java index 0db06f04ac7f..2715a0e08c1a 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerXmlTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerXmlTest.java index daa131ea690d..fff6f623052f 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerXmlTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/FileServerXmlTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/JarServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/JarServerTest.java index f8cc0169aa7d..608baf64d8d6 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/JarServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/JarServerTest.java @@ -19,7 +19,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/LikeJettyXmlTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/LikeJettyXmlTest.java index dabbcc3dff11..eafa2cc2e7be 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/LikeJettyXmlTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/LikeJettyXmlTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyConnectorsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyConnectorsTest.java index b9152f597a7d..92751c45d905 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyConnectorsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyConnectorsTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyContextsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyContextsTest.java index 8f57235d25e5..721c50c985ad 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyContextsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyContextsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyHandlersTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyHandlersTest.java index 7aa31e717a56..5660d2edcc5b 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyHandlersTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyHandlersTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyServletContextsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyServletContextsTest.java index 8b4ed10919e5..35f98fcf0046 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyServletContextsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ManyServletContextsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/MinimalServletsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/MinimalServletsTest.java index 377e0b92095a..db7f8c2e88a9 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/MinimalServletsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/MinimalServletsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneConnectorTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneConnectorTest.java index 1f180a572fdd..19b04554a24f 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneConnectorTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneConnectorTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneContextTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneContextTest.java index c4d60087411c..df9506fe165e 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneContextTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneContextTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneHandlerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneHandlerTest.java index 7f6e6ee44643..62f827701d75 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneHandlerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneHandlerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextJmxStatsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextJmxStatsTest.java index 3c0cd5550f0e..bf6e64554b57 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextJmxStatsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextJmxStatsTest.java @@ -19,7 +19,7 @@ import javax.management.ObjectInstance; import javax.management.ObjectName; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ConnectionStatistics; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextTest.java index c2bc477a41f9..5fcc392776eb 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextWithSessionTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextWithSessionTest.java index 4ae2ff9b28d8..901011686582 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextWithSessionTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneServletContextWithSessionTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppTest.java index 7ab885c186cb..fdb80797f572 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppWithJspTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppWithJspTest.java index 9e99d64cac5a..d36f23cead80 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppWithJspTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/OneWebAppWithJspTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ProxyServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ProxyServerTest.java index 8dcb0c6bf1aa..660b03457c6d 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ProxyServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ProxyServerTest.java @@ -15,8 +15,8 @@ import java.net.URI; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/RewriteServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/RewriteServerTest.java index f10454ddb7f6..4404a40300d3 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/RewriteServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/RewriteServerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SecuredHelloHandlerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SecuredHelloHandlerTest.java index 7379ad8b3bcb..8eb1d6506bb8 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SecuredHelloHandlerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SecuredHelloHandlerTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Base64; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithAnnotationsTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithAnnotationsTest.java index ed0481518ba1..e840248983fd 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithAnnotationsTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithAnnotationsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.LifeCycle; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithJNDITest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithJNDITest.java index b092d8214cfc..cf5a24f4a723 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithJNDITest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/ServerWithJNDITest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.LifeCycle; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SimplestServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SimplestServerTest.java index 6d840dd0bc9c..0dccfe0ab720 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SimplestServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SimplestServerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.junit.jupiter.api.AfterEach; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SplitFileServerTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SplitFileServerTest.java index 611b6a3530a1..187f3c5bc0f7 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SplitFileServerTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/test/java/org/eclipse/jetty/ee10/demos/SplitFileServerTest.java @@ -17,7 +17,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.resource.Resource; diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee10/demos/ProxyWebAppTest.java b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee10/demos/ProxyWebAppTest.java index 0235d20e646c..5dd9caf0988a 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee10/demos/ProxyWebAppTest.java +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee10/demos/ProxyWebAppTest.java @@ -16,8 +16,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.webapp.WebAppContext; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-openid/src/main/config/etc/jetty-ee10-openid.xml b/jetty-ee10/jetty-ee10-openid/src/main/config/etc/jetty-ee10-openid.xml index 5c68b5cfdd9c..085915563ad7 100644 --- a/jetty-ee10/jetty-ee10-openid/src/main/config/etc/jetty-ee10-openid.xml +++ b/jetty-ee10/jetty-ee10-openid/src/main/config/etc/jetty-ee10-openid.xml @@ -4,7 +4,7 @@ - + diff --git a/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdConfiguration.java b/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdConfiguration.java index e452d10b91ee..55ec01a5ef49 100644 --- a/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdConfiguration.java +++ b/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdConfiguration.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ajax.JSON; import org.eclipse.jetty.util.annotation.Name; diff --git a/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdCredentials.java b/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdCredentials.java index 8f4bbd8d3d4b..1b52b09e7a45 100644 --- a/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdCredentials.java +++ b/jetty-ee10/jetty-ee10-openid/src/main/java/org/eclipse/jetty/ee10/security/openid/OpenIdCredentials.java @@ -20,11 +20,11 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.FormRequestContent; +import org.eclipse.jetty.client.Authentication; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.ajax.JSON; import org.slf4j.Logger; diff --git a/jetty-ee10/jetty-ee10-openid/src/test/java/org/eclipse/jetty/ee10/security/openid/OpenIdAuthenticationTest.java b/jetty-ee10/jetty-ee10-openid/src/test/java/org/eclipse/jetty/ee10/security/openid/OpenIdAuthenticationTest.java index 6085df5b052d..a8eb8a317f48 100644 --- a/jetty-ee10/jetty-ee10-openid/src/test/java/org/eclipse/jetty/ee10/security/openid/OpenIdAuthenticationTest.java +++ b/jetty-ee10/jetty-ee10-openid/src/test/java/org/eclipse/jetty/ee10/security/openid/OpenIdAuthenticationTest.java @@ -22,8 +22,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.security.ConstraintMapping; import org.eclipse.jetty.ee10.servlet.security.ConstraintSecurityHandler; @@ -251,4 +251,4 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t response.getWriter().println("
Home"); } } -} \ No newline at end of file +} diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-alpn/pom.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-alpn/pom.xml index 8f05e124e5fa..3347c59e84de 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-alpn/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-alpn/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-jsp/pom.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-jsp/pom.xml index ed2b3062af23..69232f13e768 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-jsp/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-jsp/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -20,7 +20,6 @@ org.eclipse.jetty.ee10.osgi jetty-ee10-osgi-boot - ${project.version} provided @@ -54,11 +53,11 @@ set-jsp-api-version validate - parse-version + parse-version - ${jsp.impl.version} - jspImpl + ${jsp.impl.version} + jspImpl diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-warurl/pom.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-warurl/pom.xml index 8f3d886723ab..15e33de35c9a 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-warurl/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot-warurl/pom.xml @@ -1,9 +1,8 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT - ../pom.xml 4.0.0 jetty-ee10-osgi-boot-warurl diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/pom.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/pom.xml index 51ad5e3600d0..a341aa1fb92b 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -16,22 +16,18 @@ org.eclipse.jetty.ee10 jetty-ee10-annotations - ${project.version} org.eclipse.jetty.ee10 jetty-ee10-webapp - ${project.version} org.eclipse.jetty jetty-osgi - ${project.version} org.eclipse.jetty jetty-jmx - ${project.version} org.eclipse.platform diff --git a/jetty-ee10/jetty-ee10-osgi/pom.xml b/jetty-ee10/jetty-ee10-osgi/pom.xml index 906a2deefe28..144bcd5ef0d7 100644 --- a/jetty-ee10/jetty-ee10-osgi/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/pom.xml @@ -7,25 +7,11 @@ 4.0.0 org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi EE10 :: Jetty :: OSGi pom - 3.18.100 - 8.1.0 - 3.11.0 - 1.6.1 - 1.5.0 - 1.4.1 - 3.7.100 - 1.2.0 - 1.2.0 - 1.0.2 - 1.0.1 - 1.5.4 - 1.0.2 - 1.0.0-v20070606 true @@ -39,6 +25,21 @@ test-jetty-ee10-osgi + + + + org.eclipse.jetty.ee10.osgi + jetty-ee10-osgi-boot + ${project.version} + + + org.eclipse.jetty.ee10.osgi + jetty-ee10-osgi-boot-jsp + ${project.version} + + + + @@ -66,77 +67,6 @@ - - - org.apache.maven.plugins - maven-eclipse-plugin - - prevent/overwriting/by/pointing/to/nonexisting/MANIFEST.MF - true - true - - **/.svn/** - - - - - - - - org.eclipse.platform - org.eclipse.osgi.services - ${osgi-services-version} - - - - jakarta.servlet - servlet-api - - - - org.apache.felix - org.osgi.foundation - - - - - org.eclipse.platform - org.eclipse.osgi - ${osgi-version} - - - org.osgi - org.osgi.service.cm - ${osgi-service-cm-version} - - - org.osgi - org.osgi.service.component - ${osgi-service-component-version} - - - org.osgi - org.osgi.service.event - ${osgi-service-event-version} - - - org.osgi - org.osgi.util.tracker - ${osgi-util-tracker-version} - - - org.eclipse.equinox.http - servlet - ${equinox-http-servlet-version} - - - org.osgi - osgi.annotation - ${osgi-annotation-version} - - - - diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-fragment/pom.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-fragment/pom.xml index 7f0c32c06fae..4f76c689d1e5 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-fragment/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-fragment/pom.xml @@ -1,9 +1,8 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-ee10-osgi-fragment diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-server/pom.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-server/pom.xml index a2af825a8c5c..20710515f80e 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-server/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-server/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT 4.0.0 diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-webapp-resources/pom.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-webapp-resources/pom.xml index 11760d49333f..07582892a655 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-webapp-resources/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi-webapp-resources/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -16,26 +16,26 @@ - - org.apache.maven.plugins - maven-resources-plugin - - - copy-resources - validate - - copy-resources - - - ${basedir}/target/classes - - - src/main/resources - - - - - + + org.apache.maven.plugins + maven-resources-plugin + + + copy-resources + validate + + copy-resources + + + ${basedir}/target/classes + + + src/main/resources + + + + + org.apache.felix diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/pom.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/pom.xml index a8d82b27b4c5..bc1169927e7f 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/pom.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/pom.xml @@ -1,9 +1,8 @@ org.eclipse.jetty.ee10.osgi - jetty-ee10-osgi-project + jetty-ee10-osgi 12.0.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-ee10-osgi @@ -13,12 +12,6 @@ ${project.groupId}.boot.test.osgi https://download.eclipse.org/jetty/orbit/ target/distribution - 4.13.1 - 2.6.2 - 1.8.3 - 3.0.0 - 1.3.6 - 1.2 true @@ -26,20 +19,17 @@ org.ops4j.pax.exam pax-exam - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-inject - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-container-forked - ${pax.exam.version} test @@ -55,12 +45,10 @@ org.ops4j.pax.tinybundles tinybundles - ${tinybundles.version} org.ops4j.pax.swissbox pax-swissbox-framework - ${swissbox.version} test @@ -72,31 +60,26 @@ org.ops4j.pax.swissbox pax-swissbox-tracker - ${swissbox.version} test org.ops4j.pax.exam pax-exam-junit4 - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-link-mvn - ${pax.exam.version} test org.ops4j.pax.url pax-url-aether - ${pax.url.version} test org.ops4j.pax.url pax-url-wrap - ${pax.url.version} test @@ -128,37 +111,31 @@ org.eclipse.platform org.eclipse.osgi.util - ${osgi-util-version} test org.apache.geronimo.specs geronimo-atinject_1.0_spec - 1.2 test org.osgi org.osgi.util.promise - ${osgi-util-promise-version} test org.osgi org.osgi.util.measurement - ${osgi-util-measurement-version} test org.osgi org.osgi.util.position - ${osgi-util-position-version} test org.osgi org.osgi.util.xml - ${osgi-util-xml-version} test @@ -182,7 +159,6 @@ org.eclipse.jetty.ee10.osgi jetty-ee10-osgi-boot - ${project.version} test @@ -198,7 +174,6 @@ org.eclipse.jetty.ee10.osgi jetty-ee10-osgi-boot-jsp - ${project.version} test @@ -243,7 +218,6 @@ org.apache.aries.spifly org.apache.aries.spifly.dynamic.bundle - ${spifly.version} test @@ -386,7 +360,6 @@ org.eclipse.jetty jetty-alpn-server - ${project.version} test @@ -462,72 +435,60 @@ org.ow2.asm asm test - ${asm.version} org.ow2.asm asm-commons test - ${asm.version} org.ow2.asm asm-tree test - ${asm.version} org.ow2.asm asm-analysis test - ${asm.version} org.ow2.asm asm-util test - ${asm.version} org.eclipse.jetty.http2 jetty-http2-client - ${project.version} test org.eclipse.jetty.http2 jetty-http2-client-transport - ${project.version} test org.eclipse.jetty jetty-alpn-conscrypt-server - ${project.version} test org.eclipse.jetty jetty-alpn-conscrypt-client - ${project.version} test org.conscrypt conscrypt-openjdk-uber - ${conscrypt.version} test org.eclipse.jetty jetty-alpn-java-server - ${project.version} test org.eclipse.jetty jetty-alpn-java-client - ${project.version} test @@ -608,7 +569,7 @@ copy-dependencies - + test-jetty-ee10-osgi-webapp-resources diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java index 67b128118316..b1676d8476f2 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java @@ -21,8 +21,8 @@ import java.util.concurrent.Executor; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.io.ClientConnector; @@ -31,13 +31,9 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.Test; import org.junit.jupiter.api.Disabled; -import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2JDK9.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2JDK9.java index 058e4f3b026e..feeab32a3510 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2JDK9.java +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootHTTP2JDK9.java @@ -21,8 +21,8 @@ import java.util.concurrent.Executor; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithAnnotations.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithAnnotations.java index 84ca2c18b427..20c62ee47876 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithAnnotations.java +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithAnnotations.java @@ -17,16 +17,15 @@ import java.util.List; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.MultiPart; import org.junit.Test; -import org.junit.jupiter.api.Disabled; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.CoreOptions; diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithJsp.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithJsp.java index 3af895229b73..0fe126134b2a 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithJsp.java +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithJsp.java @@ -16,8 +16,8 @@ import java.util.ArrayList; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiClasspathResources.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiClasspathResources.java index 6eb0bfa97a15..a9c726a87304 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiClasspathResources.java +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiClasspathResources.java @@ -20,8 +20,8 @@ import javax.inject.Inject; import aQute.bnd.osgi.Constants; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AbstractProxyServlet.java b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AbstractProxyServlet.java index bae6e0e21d69..ce83827559d4 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AbstractProxyServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AbstractProxyServlet.java @@ -37,9 +37,9 @@ import org.eclipse.jetty.client.ContinueProtocolHandler; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.ProtocolHandlers; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServlet.java b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServlet.java index fb6b7c618aa9..b488e85a338b 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServlet.java @@ -35,13 +35,13 @@ import jakarta.servlet.WriteListener; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.client.ContentDecoder; import org.eclipse.jetty.client.GZIPContentDecoder; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.Content; @@ -439,6 +439,7 @@ public void onHeaders(Response serverResponse) @Override public void onContent(Response serverResponse, Content.Chunk chunk, Runnable demander) { + chunk.retain(); Callback callback = Callback.from(chunk::release, Callback.from(demander, serverResponse::abort)); try { diff --git a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncProxyServlet.java b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncProxyServlet.java index dea10891e1ca..f95443c88331 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncProxyServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/AsyncProxyServlet.java @@ -25,9 +25,9 @@ import jakarta.servlet.WriteListener; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.server.handler.ConnectHandler; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingCallback; diff --git a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/BalancerServlet.java b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/BalancerServlet.java index 8fcc1850c0cc..907d46e061ac 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/BalancerServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/BalancerServlet.java @@ -26,7 +26,7 @@ import jakarta.servlet.UnavailableException; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.URIUtil; public class BalancerServlet extends ProxyServlet diff --git a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/ProxyServlet.java b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/ProxyServlet.java index 82ea697feff1..1e856d91ba11 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/ProxyServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/main/java/org/eclipse/jetty/ee10/proxy/ProxyServlet.java @@ -24,11 +24,11 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.InputStreamRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.handler.ConnectHandler; import org.eclipse.jetty.util.Callback; @@ -216,6 +216,7 @@ public void onContent(Response proxyResponse, Content.Chunk chunk, Runnable dema content.get(buffer); offset = 0; } + chunk.retain(); Callback callback = Callback.from(chunk::release, Callback.from(demander, proxyResponse::abort)); onResponseContent(request, response, proxyResponse, buffer, offset, length, callback); } diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java index d07ec1673b73..f833f01df755 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/AsyncMiddleManServletTest.java @@ -47,14 +47,14 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/BalancerServletTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/BalancerServletTest.java index 5839b9c87819..a950a49f8d3e 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/BalancerServletTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/BalancerServletTest.java @@ -24,8 +24,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.rewrite.handler.RewriteHandler; diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/CachingProxyServlet.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/CachingProxyServlet.java index be71086124a8..3c9e6a5e1d6c 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/CachingProxyServlet.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/CachingProxyServlet.java @@ -21,9 +21,8 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpContentResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.Callback; /** @@ -72,7 +71,7 @@ protected void onResponseContent(HttpServletRequest request, HttpServletResponse protected void onProxyResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) { byte[] content = temp.remove(request.getRequestURI()).toByteArray(); - ContentResponse cached = new HttpContentResponse(proxyResponse, content, null, null); + ContentResponse cached = ContentResponse.from(proxyResponse, content, null, null); cache.put(request.getRequestURI(), cached); super.onProxyResponseSuccess(request, response, proxyResponse); } diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ClientAuthProxyTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ClientAuthProxyTest.java index 92c45d2b738a..38e43df3b3f3 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ClientAuthProxyTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ClientAuthProxyTest.java @@ -31,12 +31,12 @@ import javax.security.auth.x500.X500Principal; import jakarta.servlet.http.HttpServletRequest; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpScheme; @@ -560,7 +560,7 @@ private static class ProxyAliasClientSslContextFactory extends SslContextFactory @Override public SSLEngine newSslEngine(String host, int port, Map context) { - HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); + Destination destination = (Destination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); String user = (String)destination.getOrigin().getTag(); return factories.compute(user, (key, value) -> value != null ? value : this).newSSLEngine(host, port); } diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyServerTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyServerTest.java index 311e4eed2dc3..34bd0687284a 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyServerTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyServerTest.java @@ -18,11 +18,11 @@ import java.util.stream.Stream; import jakarta.servlet.http.HttpServletRequest; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyTLSServerTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyTLSServerTest.java index 8a530aaf79c9..a89e4d27aa64 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyTLSServerTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ForwardProxyTLSServerTest.java @@ -32,17 +32,17 @@ import javax.net.ssl.X509ExtendedKeyManager; import jakarta.servlet.ServletException; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpScheme; @@ -316,7 +316,7 @@ public void succeeded(Connection result) assertTrue(connectionLatch.await(5, TimeUnit.SECONDS)); String body2 = "body=" + content1; - org.eclipse.jetty.client.api.Request request2 = httpClient.newRequest("localhost", serverConnector.getLocalPort()) + org.eclipse.jetty.client.Request request2 = httpClient.newRequest("localhost", serverConnector.getLocalPort()) .scheme(HttpScheme.HTTPS.asString()) .method(HttpMethod.POST) .path("/echo") @@ -802,10 +802,10 @@ public void testRequestCompletionDelayed(SslContextFactory.Server proxyTLS) thro try { - httpClient.getRequestListeners().add(new org.eclipse.jetty.client.api.Request.Listener() + httpClient.getRequestListeners().add(new org.eclipse.jetty.client.Request.Listener() { @Override - public void onSuccess(org.eclipse.jetty.client.api.Request request) + public void onSuccess(org.eclipse.jetty.client.Request request) { if (HttpMethod.CONNECT.is(request.getMethod())) sleep(250); diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletFailureTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletFailureTest.java index 74fd65d1d947..49ffd27034f5 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletFailureTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletFailureTest.java @@ -29,13 +29,13 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletLoadTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletLoadTest.java index 1df300a152b7..af135826eb79 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletLoadTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletLoadTest.java @@ -23,10 +23,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BytesRequestContent; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletTest.java index a537f276da0d..43489b03f831 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ProxyServletTest.java @@ -59,19 +59,19 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequestWrapper; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; import org.eclipse.jetty.client.ConnectionPool; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; +import org.eclipse.jetty.client.InputStreamResponseListener; import org.eclipse.jetty.client.ProxyConfiguration.Proxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.ee10.servlet.FilterHolder; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletContextRequest; @@ -1293,7 +1293,7 @@ private boolean await(CountDownLatch latch, long ms) throws IOException // Make sure the proxy does not receive chunk2. assertEquals(-1, input.read()); - HttpDestination destination = (HttpDestination)client.resolveDestination(request); + Destination destination = client.resolveDestination(request); ConnectionPool connectionPool = destination.getConnectionPool(); assertTrue(connectionPool.isEmpty()); } @@ -1366,7 +1366,7 @@ private boolean await(CountDownLatch latch, long ms) throws IOException input.read(); }); - HttpDestination destination = (HttpDestination)client.resolveDestination(request); + Destination destination = client.resolveDestination(request); ConnectionPool connectionPool = destination.getConnectionPool(); assertTrue(connectionPool.isEmpty()); } diff --git a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ReverseProxyTest.java b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ReverseProxyTest.java index a90814898cb1..55949121022c 100644 --- a/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ReverseProxyTest.java +++ b/jetty-ee10/jetty-ee10-proxy/src/test/java/org/eclipse/jetty/ee10/proxy/ReverseProxyTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.HttpConfiguration; diff --git a/jetty-ee10/jetty-ee10-runner/src/test/java/org/eclipse/jetty/ee10/maven/jettyrunner/it/IntegrationTestJettyRunner.java b/jetty-ee10/jetty-ee10-runner/src/test/java/org/eclipse/jetty/ee10/maven/jettyrunner/it/IntegrationTestJettyRunner.java index b85ac37ceb50..f715853e25d2 100644 --- a/jetty-ee10/jetty-ee10-runner/src/test/java/org/eclipse/jetty/ee10/maven/jettyrunner/it/IntegrationTestJettyRunner.java +++ b/jetty-ee10/jetty-ee10-runner/src/test/java/org/eclipse/jetty/ee10/maven/jettyrunner/it/IntegrationTestJettyRunner.java @@ -18,8 +18,8 @@ import java.nio.file.Paths; import java.util.List; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/AsyncContentProducer.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/AsyncContentProducer.java index 06dcd7e83daa..39f809480e54 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/AsyncContentProducer.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/AsyncContentProducer.java @@ -58,11 +58,12 @@ public void recycle() if (LOG.isDebugEnabled()) LOG.debug("recycling {}", this); - // Make sure that the chunk has been fully consumed before destroying the interceptor and also make sure - // that asking this instance for chunks between recycle and reopen will only produce error'ed chunks. + // Make sure that asking this instance for chunks between + // recycle() and reopen() will only produce error chunks. if (_chunk == null) _chunk = RECYCLED_ERROR_CHUNK; - else if (!_chunk.isTerminal()) + // The chunk must be fully consumed. + else if (!_chunk.isLast() || _chunk.hasRemaining()) throw new IllegalStateException("ContentProducer with unconsumed chunk cannot be recycled"); } @@ -168,15 +169,14 @@ public boolean consumeAvailable() private boolean consumeCurrentChunk() { - if (_chunk != null && !_chunk.isTerminal()) + if (_chunk != null) { if (LOG.isDebugEnabled()) - LOG.debug("releasing current chunk {}", this); + LOG.debug("consuming and releasing current chunk {}", this); _chunk.skip(_chunk.remaining()); _chunk.release(); _chunk = _chunk.isLast() ? Content.Chunk.EOF : null; } - return _chunk != null && _chunk.isLast(); } @@ -191,8 +191,8 @@ private boolean consumeAvailableChunks() chunk.release(); - if (chunk.isTerminal()) - return chunk.isLast(); + if (chunk.isLast()) + return true; } } @@ -266,7 +266,7 @@ private Content.Chunk produceChunk() { if (_chunk != null) { - if (_chunk.isTerminal() || _chunk.hasRemaining()) + if (_chunk.isLast() || _chunk.hasRemaining()) { if (LOG.isDebugEnabled()) LOG.debug("chunk not yet depleted, returning it {}", this); @@ -276,7 +276,6 @@ private Content.Chunk produceChunk() { if (LOG.isDebugEnabled()) LOG.debug("current chunk depleted {}", this); - _chunk.release(); _chunk = null; } @@ -299,7 +298,7 @@ private Content.Chunk produceChunk() } // Release the chunk immediately, if it is empty. - if (_chunk != null && !_chunk.hasRemaining() && !_chunk.isTerminal()) + if (_chunk != null && !_chunk.hasRemaining() && !_chunk.isLast()) { if (LOG.isDebugEnabled()) LOG.debug("releasing empty chunk {}", this); diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/Dispatcher.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/Dispatcher.java index 12426e04a076..aa5f9f6c2981 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/Dispatcher.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/Dispatcher.java @@ -35,6 +35,7 @@ import org.eclipse.jetty.ee10.servlet.util.ServletOutputStreamWrapper; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.pathmap.MatchedResource; +import org.eclipse.jetty.server.Request; import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.MultiMap; import org.eclipse.jetty.util.StringUtil; @@ -55,6 +56,11 @@ public class Dispatcher implements RequestDispatcher * Dispatch include attribute names */ public static final String __FORWARD_PREFIX = "jakarta.servlet.forward."; + + /** + * Name of original request attribute + */ + public static final String __ORIGINAL_REQUEST = "org.eclipse.jetty.originalRequest"; private final ServletContextHandler _contextHandler; private final HttpURI _uri; @@ -271,21 +277,44 @@ public String getRequestURI() @Override public Object getAttribute(String name) { - switch (name) + if (name == null) + return null; + + //Servlet Spec 9.4.2 no forward attributes if a named dispatcher + if (_named != null && name.startsWith(__FORWARD_PREFIX)) + return null; + + //Servlet Spec 9.4.2 must return the values from the original request + if (name.startsWith(__FORWARD_PREFIX)) { - case RequestDispatcher.FORWARD_REQUEST_URI: - return _httpServletRequest.getRequestURI(); - case RequestDispatcher.FORWARD_SERVLET_PATH: - return _httpServletRequest.getServletPath(); - case RequestDispatcher.FORWARD_PATH_INFO: - return _httpServletRequest.getPathInfo(); - case RequestDispatcher.FORWARD_CONTEXT_PATH: - return _httpServletRequest.getContextPath(); - case RequestDispatcher.FORWARD_MAPPING: - return _httpServletRequest.getHttpServletMapping(); - case RequestDispatcher.FORWARD_QUERY_STRING: - return _httpServletRequest.getQueryString(); + HttpServletRequest originalRequest = (HttpServletRequest)super.getAttribute(__ORIGINAL_REQUEST); + if (originalRequest == null) + originalRequest = _httpServletRequest; + + switch (name) + { + case RequestDispatcher.FORWARD_REQUEST_URI: + return originalRequest.getRequestURI(); + case RequestDispatcher.FORWARD_SERVLET_PATH: + return originalRequest.getServletPath(); + case RequestDispatcher.FORWARD_PATH_INFO: + return originalRequest.getPathInfo(); + case RequestDispatcher.FORWARD_CONTEXT_PATH: + return originalRequest.getContextPath(); + case RequestDispatcher.FORWARD_MAPPING: + return originalRequest.getHttpServletMapping(); + case RequestDispatcher.FORWARD_QUERY_STRING: + return originalRequest.getQueryString(); + default: + return super.getAttribute(name); + } + } + switch (name) + { + case __ORIGINAL_REQUEST: + HttpServletRequest originalRequest = (HttpServletRequest)super.getAttribute(name); + return originalRequest == null ? _httpServletRequest : originalRequest; // Forward should hide include. case RequestDispatcher.INCLUDE_MAPPING: case RequestDispatcher.INCLUDE_SERVLET_PATH: @@ -304,6 +333,11 @@ public Object getAttribute(String name) public Enumeration getAttributeNames() { ArrayList names = new ArrayList<>(Collections.list(super.getAttributeNames())); + + //Servlet Spec 9.4.2 no forward attributes if a named dispatcher + if (_named != null) + return Collections.enumeration(names); + names.add(RequestDispatcher.FORWARD_REQUEST_URI); names.add(RequestDispatcher.FORWARD_SERVLET_PATH); names.add(RequestDispatcher.FORWARD_PATH_INFO); @@ -333,6 +367,13 @@ public DispatcherType getDispatcherType() @Override public Object getAttribute(String name) { + if (name == null) + return null; + + //Servlet Spec 9.3.1 no include attributes if a named dispatcher + if (_named != null && name.startsWith(__INCLUDE_PREFIX)) + return null; + switch (name) { case RequestDispatcher.INCLUDE_MAPPING: @@ -355,7 +396,11 @@ public Object getAttribute(String name) @Override public Enumeration getAttributeNames() { + //Servlet Spec 9.3.1 no include attributes if a named dispatcher ArrayList names = new ArrayList<>(Collections.list(super.getAttributeNames())); + if (_named != null) + return Collections.enumeration(names); + names.add(RequestDispatcher.INCLUDE_MAPPING); names.add(RequestDispatcher.INCLUDE_SERVLET_PATH); names.add(RequestDispatcher.INCLUDE_PATH_INFO); diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpInput.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpInput.java index 40e4aa938f7c..460e42430e75 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpInput.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpInput.java @@ -245,7 +245,7 @@ private int read(ByteBuffer buffer, byte[] b, int off, int len) throws IOExcepti Content.Chunk chunk = _contentProducer.nextChunk(); if (chunk == null) throw new IllegalStateException("read on unready input"); - if (!chunk.isTerminal()) + if (chunk.hasRemaining()) { int read = buffer == null ? get(chunk, b, off, len) : get(chunk, buffer); if (LOG.isDebugEnabled()) @@ -343,31 +343,28 @@ public void run() return; } - if (chunk.isTerminal()) + if (chunk instanceof Content.Chunk.Error errorChunk) { - if (chunk instanceof Content.Chunk.Error errorChunk) + Throwable error = errorChunk.getCause(); + if (LOG.isDebugEnabled()) + LOG.debug("running error={} {}", error, this); + // TODO is this necessary to add here? + _servletChannel.getResponse().getHeaders().add(HttpFields.CONNECTION_CLOSE); + _readListener.onError(error); + } + else if (chunk.isLast() && !chunk.hasRemaining()) + { + try { - Throwable error = errorChunk.getCause(); if (LOG.isDebugEnabled()) - LOG.debug("running error={} {}", error, this); - // TODO is this necessary to add here? - _servletChannel.getResponse().getHeaders().add(HttpFields.CONNECTION_CLOSE); - _readListener.onError(error); + LOG.debug("running at EOF {}", this); + _readListener.onAllDataRead(); } - else if (chunk == Content.Chunk.EOF) + catch (Throwable x) { - try - { - if (LOG.isDebugEnabled()) - LOG.debug("running at EOF {}", this); - _readListener.onAllDataRead(); - } - catch (Throwable x) - { - if (LOG.isDebugEnabled()) - LOG.debug("running failed onAllDataRead {}", this, x); - _readListener.onError(x); - } + if (LOG.isDebugEnabled()) + LOG.debug("running failed onAllDataRead {}", this, x); + _readListener.onError(x); } } else diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletMultiPartFormData.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletMultiPartFormData.java index f6634997c74c..30d667bb41e4 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletMultiPartFormData.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletMultiPartFormData.java @@ -111,7 +111,9 @@ private Parts parse(ServletContextRequest.ServletApiRequest request) throws IOEx formData.parse(Content.Chunk.EOF); break; } - formData.parse(Content.Chunk.from(ByteBuffer.wrap(buffer, 0, read), false)); + Content.Chunk chunk = Content.Chunk.from(ByteBuffer.wrap(buffer, 0, read), false); + formData.parse(chunk); + chunk.release(); } return new Parts(formData); diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ComponentWrapTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ComponentWrapTest.java index 395a83f6ccba..fcf075a8df27 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ComponentWrapTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ComponentWrapTest.java @@ -35,8 +35,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DispatcherTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DispatcherTest.java index 821ab747f238..aa9239cfb9da 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DispatcherTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DispatcherTest.java @@ -137,6 +137,42 @@ public void testForward() throws Exception assertEquals(expected, rawResponse); } + @Test + public void testFowardThenForward() throws Exception + { + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(AlwaysForwardServlet.class, "/AlwaysForwardServlet/*"); + _contextHandler.addServlet(ForwardEchoURIServlet.class, "/echo/*"); + + + String rawResponse = _connector.getResponse(""" + GET /context/ForwardServlet?do=always HTTP/1.1\r + Host: local\r + Connection: close\r + \r + """); + + String expected = """ + HTTP/1.1 200 OK\r + Content-Type: text/plain\r + Content-Length: 123\r + Connection: close\r + \r + /context\r + /echo\r + null\r + /context/echo\r + /context\r + ForwardServlet\r + null\r + do=always\r + /context/ForwardServlet\r + /ForwardServlet\r + """; + + assertEquals(expected, rawResponse); + } + @Test public void testForwardNonUTF8() throws Exception { @@ -191,7 +227,7 @@ public void testForwardWithParam() throws Exception public void testNamedForward() throws Exception { _contextHandler.addServlet(NamedForwardServlet.class, "/forward/*"); - String echo = _contextHandler.addServlet(EchoURIServlet.class, "/echo/*").getName(); + String echo = _contextHandler.addServlet(ForwardEchoURIServlet.class, "/echo/*").getName(); String rawResponse = _connector.getResponse((""" GET /context/forward/info;param=value?name=@ECHO@ HTTP/1.1\r @@ -203,13 +239,19 @@ public void testNamedForward() throws Exception String expected = """ HTTP/1.1 200 OK\r Content-Type: text/plain\r - Content-Length: 62\r + Content-Length: 98\r Connection: close\r \r /context\r /forward\r /info\r /context/forward/info;param=value\r + null\r + null\r + null\r + null\r + null\r + null\r """; assertEquals(expected, rawResponse); @@ -219,7 +261,7 @@ public void testNamedForward() throws Exception public void testNamedInclude() throws Exception { _contextHandler.addServlet(NamedIncludeServlet.class, "/include/*"); - String echo = _contextHandler.addServlet(EchoURIServlet.class, "/echo/*").getName(); + String echo = _contextHandler.addServlet(IncludeEchoURIServlet.class, "/echo/*").getName(); String responses = _connector.getResponse(""" GET /context/include/info;param=value?name=@ECHO@ HTTP/1.1\r @@ -230,13 +272,19 @@ public void testNamedInclude() throws Exception String expected = """ HTTP/1.1 200 OK\r - Content-Length: 62\r + Content-Length: 98\r Connection: close\r \r /context\r /include\r /info\r /context/include/info;param=value\r + null\r + null\r + null\r + null\r + null\r + null\r """; assertEquals(expected, responses); @@ -811,6 +859,8 @@ else if (request.getParameter("do").equals("ctx.echo")) dispatcher = getServletContext().getRequestDispatcher(request.getParameter("uri")); else if (request.getParameter("do").equals("req.echo")) dispatcher = request.getRequestDispatcher(request.getParameter("uri")); + else if (request.getParameter("do").equals("always")) + dispatcher = request.getRequestDispatcher("/AlwaysForwardServlet"); assert dispatcher != null; dispatcher.forward(request, response); } @@ -1120,6 +1170,48 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t response.getOutputStream().println(request.getRequestURI()); } } + + public static class IncludeEchoURIServlet extends HttpServlet implements Servlet + { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + response.setContentType("text/plain"); + response.setStatus(HttpServletResponse.SC_OK); + response.getOutputStream().println(request.getContextPath()); + response.getOutputStream().println(request.getServletPath()); + response.getOutputStream().println(request.getPathInfo()); + response.getOutputStream().println(request.getRequestURI()); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH)); + HttpServletMapping mapping = (HttpServletMapping)request.getAttribute(RequestDispatcher.INCLUDE_MAPPING); + response.getOutputStream().println(mapping == null ? null : mapping.getMatchValue()); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.INCLUDE_QUERY_STRING)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH)); + } + } + + public static class ForwardEchoURIServlet extends HttpServlet implements Servlet + { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + response.setContentType("text/plain"); + response.setStatus(HttpServletResponse.SC_OK); + response.getOutputStream().println(request.getContextPath()); + response.getOutputStream().println(request.getServletPath()); + response.getOutputStream().println(request.getPathInfo()); + response.getOutputStream().println(request.getRequestURI()); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH)); + HttpServletMapping mapping = (HttpServletMapping)request.getAttribute(RequestDispatcher.FORWARD_MAPPING); + response.getOutputStream().println(mapping == null ? null : mapping.getMatchValue()); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.FORWARD_PATH_INFO)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI)); + response.getOutputStream().println((String)request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH)); + } + } public static class AssertForwardServlet extends HttpServlet implements Servlet { diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/FormTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/FormTest.java index ce9a525aa022..578bb225321d 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/FormTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/FormTest.java @@ -22,10 +22,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.FormRequestContent; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerBreakEvenSizeTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerBreakEvenSizeTest.java index 0959444894ba..dc18a6329184 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerBreakEvenSizeTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerBreakEvenSizeTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerCommitTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerCommitTest.java index 5a5aa9338245..597051162900 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerCommitTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/GzipHandlerCommitTest.java @@ -23,9 +23,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/InitServletTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/InitServletTest.java index e487ae6d6b0f..bb6f038caae6 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/InitServletTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/InitServletTest.java @@ -23,8 +23,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/MultiPartServletTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/MultiPartServletTest.java index 73b29b5102f9..b9f2b852b8dd 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/MultiPartServletTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/MultiPartServletTest.java @@ -31,13 +31,13 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.Part; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/SessionHandlerTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/SessionHandlerTest.java index b87ab05a83de..85f50a7fc1b9 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/SessionHandlerTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/SessionHandlerTest.java @@ -35,8 +35,8 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.Request; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AbstractTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AbstractTest.java index 62ec0cc94f0e..355a46a5a90b 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AbstractTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AbstractTest.java @@ -24,10 +24,10 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.fcgi.server.ServerFCGIConnectionFactory; import org.eclipse.jetty.http2.HTTP2Cipher; import org.eclipse.jetty.http2.client.HTTP2Client; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AsyncIOServletTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AsyncIOServletTest.java index 23561c1b5a64..c4cd7937f3d9 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AsyncIOServletTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/AsyncIOServletTest.java @@ -41,16 +41,16 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.InputStreamRequestContent; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.OutputStreamRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.ee10.servlet.HttpOutput; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; @@ -1142,9 +1142,9 @@ public void onError(Throwable x) }); Destination destination = client.resolveDestination(request); - FuturePromise promise = new FuturePromise<>(); + FuturePromise promise = new FuturePromise<>(); destination.newConnection(promise); - org.eclipse.jetty.client.api.Connection connection = promise.get(5, TimeUnit.SECONDS); + org.eclipse.jetty.client.Connection connection = promise.get(5, TimeUnit.SECONDS); CountDownLatch clientLatch = new CountDownLatch(1); connection.send(request, result -> { diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/BlockedIOTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/BlockedIOTest.java index 59b8191c1bda..9c79a29d9cab 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/BlockedIOTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/BlockedIOTest.java @@ -22,7 +22,7 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.junit.jupiter.api.Disabled; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpClientContinueTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpClientContinueTest.java index 0c92d301cc27..a972969ad72f 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpClientContinueTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpClientContinueTest.java @@ -34,15 +34,15 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.ContinueProtocolHandler; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.FutureResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; @@ -306,7 +306,7 @@ public void onComplete(Result result) @MethodSource("transportsNoFCGI") public void testExpect100ContinueWithContentWithResponseFailureBefore100Continue(Transport transport) throws Exception { - AtomicReference clientRequestRef = new AtomicReference<>(); + AtomicReference clientRequestRef = new AtomicReference<>(); CountDownLatch clientLatch = new CountDownLatch(1); CountDownLatch serverLatch = new CountDownLatch(1); @@ -330,7 +330,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) }); byte[] content = new byte[1024]; - org.eclipse.jetty.client.api.Request clientRequest = client.newRequest(newURI(transport)); + Request clientRequest = client.newRequest(newURI(transport)); clientRequestRef.set(clientRequest); clientRequest .headers(headers -> headers.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) @@ -355,7 +355,7 @@ public void onComplete(Result result) @MethodSource("transportsNoFCGI") public void testExpect100ContinueWithContentWithResponseFailureAfter100Continue(Transport transport) throws Exception { - AtomicReference clientRequestRef = new AtomicReference<>(); + AtomicReference clientRequestRef = new AtomicReference<>(); CountDownLatch clientLatch = new CountDownLatch(1); CountDownLatch serverLatch = new CountDownLatch(1); start(transport, new HttpServlet() @@ -380,7 +380,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) }); byte[] content = new byte[1024]; - org.eclipse.jetty.client.api.Request clientRequest = client.newRequest(newURI(transport)); + Request clientRequest = client.newRequest(newURI(transport)); clientRequestRef.set(clientRequest); clientRequest .headers(headers -> headers.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpTrailersTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpTrailersTest.java index 7cb1d1240624..35c34e12baaf 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpTrailersTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/HttpTrailersTest.java @@ -30,11 +30,11 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -177,8 +177,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = r.getTrailers(); assertNotNull(trailers); assertEquals(trailerValue, trailers.get(trailerName)); failure.set(null); @@ -199,8 +198,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - assertNull(httpResponse.getTrailers()); + assertNull(r.getTrailers()); failure.set(null); } catch (Throwable x) @@ -233,8 +231,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = r.getTrailers(); assertNull(trailers); failure.set(null); } @@ -275,7 +272,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) client.newRequest(newURI(transport)) .timeout(15, TimeUnit.SECONDS) .send(listener); - org.eclipse.jetty.client.api.Response response = listener.get(5, TimeUnit.SECONDS); + Response response = listener.get(5, TimeUnit.SECONDS); assertEquals(HttpStatus.OK_200, response.getStatus()); InputStream input = listener.getInputStream(); @@ -295,8 +292,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) // Wait for the request/response cycle to complete. listener.await(5, TimeUnit.SECONDS); - HttpResponse httpResponse = (HttpResponse)response; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = response.getTrailers(); assertNotNull(trailers); assertEquals(trailerValue, trailers.get(trailerName)); } @@ -330,7 +326,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) .timeout(5, TimeUnit.SECONDS) .send(result -> { - HttpResponse response = (HttpResponse)result.getResponse(); + Response response = result.getResponse(); assertEquals(HttpStatus.OK_200, response.getStatus()); assertNull(response.getTrailers()); assertNull(response.getHeaders().get("name")); diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/InformationalResponseTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/InformationalResponseTest.java index 1637e592a400..d0e1681cd300 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/InformationalResponseTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/InformationalResponseTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/PushCacheFilterTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/PushCacheFilterTest.java index 6c396b66d824..491b1fa94ce8 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/PushCacheFilterTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/PushCacheFilterTest.java @@ -25,10 +25,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.ee10.servlets.PushCacheFilter; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; @@ -196,7 +196,7 @@ else if (requestURI.endsWith(secondaryResource)) assertTrue(pushLatch.await(5, TimeUnit.SECONDS)); // Make sure the connection is sane. - HttpDestination destination = (HttpDestination)client.getDestinations().get(0); + Destination destination = client.getDestinations().get(0); assertFalse(destination.getConnectionPool().isEmpty()); } diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/RequestReaderTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/RequestReaderTest.java index bdbe8fcd0551..0d4c99947d8c 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/RequestReaderTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/RequestReaderTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/ServerTimeoutsTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/ServerTimeoutsTest.java index 011f38474c98..63326e15f7f7 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/ServerTimeoutsTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/ServerTimeoutsTest.java @@ -33,10 +33,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http2.FlowControlStrategy; @@ -600,7 +600,6 @@ protected void service(HttpServletRequest request, HttpServletResponse response) .onResponseContentAsync((response, chunk, demander) -> { objects.offer(chunk.remaining()); - chunk.release(); objects.offer(demander); }) .send(result -> diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/VirtualThreadsTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/VirtualThreadsTest.java index e623699b2bbd..6243710f28ce 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/VirtualThreadsTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-client-transports/src/test/java/org/eclipse/jetty/ee10/test/client/transport/VirtualThreadsTest.java @@ -30,8 +30,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.VirtualThreads; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/DataSourceLoginServiceTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/DataSourceLoginServiceTest.java index efc32da459d9..21d086b1f935 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/DataSourceLoginServiceTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/DataSourceLoginServiceTest.java @@ -21,10 +21,10 @@ import java.sql.Statement; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BasicAuthentication; import org.eclipse.jetty.ee10.plus.security.DataSourceLoginService; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/JdbcLoginServiceTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/JdbcLoginServiceTest.java index babf2aebda4a..22790787c5c2 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/JdbcLoginServiceTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-loginservice/src/test/java/org/eclipse/jetty/ee10/loginservice/JdbcLoginServiceTest.java @@ -22,12 +22,12 @@ import java.nio.charset.StandardCharsets; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.security.JDBCLoginService; import org.eclipse.jetty.ee10.servlet.security.LoginService; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml index 4e9381936751..66aa233e619b 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml @@ -2,7 +2,7 @@ - + diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee10/tests/webapp/websocket/WebSocketClientServlet.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee10/tests/webapp/websocket/WebSocketClientServlet.java index e9498bd37106..a0b01057b5f8 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee10/tests/webapp/websocket/WebSocketClientServlet.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee10/tests/webapp/websocket/WebSocketClientServlet.java @@ -25,7 +25,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketClose; import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketConnect; diff --git a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java index 2f33969c4da4..ec8c8bfd0925 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java +++ b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/HugeResourceTest.java @@ -38,14 +38,14 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.PathRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.PathRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee10.servlet.DefaultServlet; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpFields; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/JsrUpgradeListener.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/JsrUpgradeListener.java index 32d098feb259..43d8cb63819d 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/JsrUpgradeListener.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/JsrUpgradeListener.java @@ -21,8 +21,8 @@ import jakarta.websocket.ClientEndpointConfig.Configurator; import jakarta.websocket.HandshakeResponse; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.websocket.core.client.UpgradeListener; @@ -36,7 +36,7 @@ public JsrUpgradeListener(Configurator configurator) } @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { if (configurator == null) return; @@ -62,7 +62,7 @@ public void onHandshakeRequest(HttpRequest request) } @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { if (configurator == null) return; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java index 138abfebea7f..a0f2c1d1c0a7 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java @@ -20,7 +20,7 @@ import jakarta.websocket.ClientEndpointConfig; import jakarta.websocket.WebSocketContainer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.jmx.MBeanContainer; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml index f2bab0819842..6e8e0b591b54 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml @@ -2,7 +2,7 @@ - + @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientClassLoaderTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientClassLoaderTest.java index 2751cd53ed9b..2cfc3e338176 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientClassLoaderTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientClassLoaderTest.java @@ -28,9 +28,9 @@ import jakarta.websocket.Session; import jakarta.websocket.WebSocketContainer; import jakarta.websocket.server.ServerEndpoint; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.webapp.Configuration; import org.eclipse.jetty.ee10.webapp.Configurations; import org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java index 84dbf70b2917..884b115312ba 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.websocket.ContainerProvider; import jakarta.websocket.WebSocketContainer; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketShutdownContainer; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java index 0c94fd44a1bf..284ee1d3bc84 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.websocket.ContainerProvider; import jakarta.websocket.WebSocketContainer; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.webapp.Configuration; import org.eclipse.jetty.ee10.webapp.Configurations; import org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml index eef3def74100..10037cbff039 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml @@ -4,7 +4,7 @@ - + ws://localhost:/secured/socket diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/JettyUpgradeListener.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/JettyUpgradeListener.java index 0e9079f84937..c378995495a7 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/JettyUpgradeListener.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/JettyUpgradeListener.java @@ -13,8 +13,8 @@ package org.eclipse.jetty.ee10.websocket.client; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; public interface JettyUpgradeListener { @@ -23,7 +23,7 @@ public interface JettyUpgradeListener * * @param request the request */ - default void onHandshakeRequest(HttpRequest request) + default void onHandshakeRequest(Request request) { } @@ -33,7 +33,7 @@ default void onHandshakeRequest(HttpRequest request) * @param request the request that was used * @param response the response that was received */ - default void onHandshakeResponse(HttpRequest request, HttpResponse response) + default void onHandshakeResponse(Request request, Response response) { } } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/WebSocketClient.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/WebSocketClient.java index cdb03237654d..c20c5c59846e 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/WebSocketClient.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/WebSocketClient.java @@ -28,9 +28,8 @@ import java.util.function.Consumer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.api.WebSocketBehavior; import org.eclipse.jetty.ee10.websocket.api.WebSocketContainer; @@ -138,13 +137,13 @@ public CompletableFuture connect(Object websocket, URI toUri, ClientUpg upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { upgradeListener.onHandshakeRequest(request); } @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { upgradeListener.onHandshakeResponse(request, response); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java index 25e413952758..6a2e72ed0988 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java @@ -34,7 +34,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; /** - * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest} + * Representing the Jetty {@link org.eclipse.jetty.client.Request} * in the {@link UpgradeRequest} interface. */ public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest @@ -82,7 +82,7 @@ public Map> getHeaders() @Override public String getHost() { - return delegate.getHost(); + return delegate.getURI().getHost(); } @Override @@ -127,7 +127,7 @@ public String getProtocolVersion() @Override public String getQueryString() { - return delegate.getQuery(); + return delegate.getURI().getRawQuery(); } @Override @@ -154,7 +154,7 @@ public boolean hasSubProtocol(String test) @Override public boolean isSecure() { - return HttpClient.isSchemeSecure(delegate.getScheme()); + return HttpClient.isSchemeSecure(delegate.getURI().getScheme()); } @Override diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index 6420200ab2ad..d4d440171d62 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -20,20 +20,20 @@ import java.util.Set; import java.util.stream.Collectors; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.websocket.api.ExtensionConfig; import org.eclipse.jetty.ee10.websocket.api.UpgradeResponse; import org.eclipse.jetty.http.HttpHeader; /** - * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse} + * Representing the Jetty {@link org.eclipse.jetty.client.Response} * in the {@link UpgradeResponse} interface. */ public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse { - private final HttpResponse delegate; + private final Response delegate; - public DelegatedJettyClientUpgradeResponse(HttpResponse response) + public DelegatedJettyClientUpgradeResponse(Response response) { this.delegate = response; } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/JettyClientUpgradeRequest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/JettyClientUpgradeRequest.java index 6f75268b3402..966317a42b05 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/JettyClientUpgradeRequest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee10/websocket/client/impl/JettyClientUpgradeRequest.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.ee10.websocket.common.JettyWebSocketFrameHandler; import org.eclipse.jetty.ee10.websocket.common.JettyWebSocketFrameHandlerFactory; @@ -57,7 +57,7 @@ public JettyClientUpgradeRequest(WebSocketCoreClient coreClient, ClientUpgradeRe } @Override - public void upgrade(HttpResponse response, EndPoint endPoint) + public void upgrade(Response response, EndPoint endPoint) { frameHandler.setUpgradeRequest(new DelegatedJettyClientUpgradeRequest(this)); frameHandler.setUpgradeResponse(new DelegatedJettyClientUpgradeResponse(response)); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/ConnectionHeaderTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/ConnectionHeaderTest.java index 295e6d1386d5..f89bae6e589f 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/ConnectionHeaderTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/ConnectionHeaderTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.client.JettyUpgradeListener; @@ -74,7 +74,7 @@ public void testConnectionKeepAlive(String connectionHeaderValue) throws Excepti JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { HttpFields fields = request.getHeaders(); if (!(fields instanceof HttpFields.Mutable)) @@ -98,4 +98,4 @@ public void onHandshakeRequest(HttpRequest request) assertThat("Text Frame.status code", response, is(msg)); } } -} \ No newline at end of file +} diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyClientClassLoaderTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyClientClassLoaderTest.java index 885a429676b4..ff9307626065 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyClientClassLoaderTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyClientClassLoaderTest.java @@ -23,9 +23,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.api.WebSocketPolicy; import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketConnect; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketExtensionConfigTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketExtensionConfigTest.java index d9dbea8daee7..94e1b3f7c797 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketExtensionConfigTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketExtensionConfigTest.java @@ -19,8 +19,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.websocket.api.ExtensionConfig; import org.eclipse.jetty.ee10.websocket.api.Session; @@ -105,7 +105,7 @@ public void testJettyExtensionConfig() throws Exception JettyUpgradeListener listener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { String extensions = response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketNegotiationTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketNegotiationTest.java index 59583b7e17c3..b89a6e5d9efc 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketNegotiationTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/JettyWebSocketNegotiationTest.java @@ -19,8 +19,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.client.ClientUpgradeRequest; @@ -130,21 +130,21 @@ public void testManualNegotiationInCreator() throws Exception URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/filterPath"); EventSocket socket = new EventSocket(); - AtomicReference responseReference = new AtomicReference<>(); + AtomicReference responseReference = new AtomicReference<>(); ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); upgradeRequest.addExtensions("permessage-deflate;client_no_context_takeover"); JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { responseReference.set(response); } }; client.connect(socket, uri, upgradeRequest, upgradeListener).get(5, TimeUnit.SECONDS); - HttpResponse httpResponse = responseReference.get(); - String extensions = httpResponse.getHeaders().get("Sec-WebSocket-Extensions"); + Response response = responseReference.get(); + String extensions = response.getHeaders().get("Sec-WebSocket-Extensions"); assertThat(extensions, is("permessage-deflate")); } } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java index 6f33721a0dcf..b29d32bd0d0c 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java @@ -29,8 +29,8 @@ import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.ee10.servlet.ServletChannel; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketServletExamplesTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketServletExamplesTest.java index d6da4213fe5b..0e5e054b4dfc 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketServletExamplesTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketServletExamplesTest.java @@ -17,8 +17,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.util.BasicAuthentication; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BasicAuthentication; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.security.ConstraintMapping; import org.eclipse.jetty.ee10.servlet.security.ConstraintSecurityHandler; diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ConnectFutureTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ConnectFutureTest.java index 1a3bc03bb76e..4768a4f91760 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ConnectFutureTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ConnectFutureTest.java @@ -22,8 +22,8 @@ import java.util.concurrent.TimeoutException; import java.util.function.Consumer; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.websocket.api.Session; import org.eclipse.jetty.ee10.websocket.api.StatusCode; @@ -170,7 +170,7 @@ public void testAbortInHandshakeResponse() throws Exception JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { try { @@ -373,4 +373,4 @@ public void onWebSocketConnect(Session session) assertThat(endpointError, instanceOf(WebSocketException.class)); assertThat(endpointError.getMessage(), is("custom exception")); } -} \ No newline at end of file +} diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java index a9fe26e3677b..62c5457aa012 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java @@ -20,13 +20,12 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.session.AbstractSessionTestBase; import org.eclipse.jetty.ee10.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; -import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Testcontainers; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java index cf61907216fb..2b3ddec75b12 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java @@ -19,9 +19,9 @@ import java.net.URLClassLoader; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.session.SessionTestSupport; import org.eclipse.jetty.ee10.webapp.WebAppContext; import org.eclipse.jetty.logging.StacklessLogging; @@ -29,7 +29,6 @@ import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.testcontainers.junit.jupiter.Testcontainers; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java index 6476649f7b37..f6f062198457 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.session.SessionTestSupport; import org.eclipse.jetty.memcached.sessions.MemcachedTestHelper.MockDataStore; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java index 370d6cfe1d22..2a372501ded4 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredInvalidationSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredInvalidationSessionTest.java index 1ab29ad1ccd4..46c54eae245c 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredInvalidationSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredInvalidationSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredOrphanedSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredOrphanedSessionTest.java index 998f95290dec..ebb0f3c77b93 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredOrphanedSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredOrphanedSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredSessionScavengingTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredSessionScavengingTest.java index ff5d1f6dacca..47462f76ab69 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredSessionScavengingTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractClusteredSessionScavengingTest.java @@ -26,9 +26,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.ee10.servlet.SessionHandler; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractWebAppObjectInSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractWebAppObjectInSessionTest.java index 8ee22172fb15..48998f7f22a5 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractWebAppObjectInSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/main/java/org/eclipse/jetty/ee10/session/AbstractWebAppObjectInSessionTest.java @@ -16,12 +16,11 @@ import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; -import java.net.URL; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.webapp.WebAppContext; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/AsyncTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/AsyncTest.java index f221ca17614f..607683d4bc83 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/AsyncTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/AsyncTest.java @@ -24,8 +24,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ClientCrossContextSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ClientCrossContextSessionTest.java index 8914cde3cba6..9be5e5d1cb13 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ClientCrossContextSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ClientCrossContextSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ConcurrencyTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ConcurrencyTest.java index d49af7706187..8b07ef16956b 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ConcurrencyTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ConcurrencyTest.java @@ -25,9 +25,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.SessionCache; import org.eclipse.jetty.session.SessionDataStoreFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/CreationTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/CreationTest.java index 51b21c860515..c2e36d959d62 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/CreationTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/CreationTest.java @@ -24,9 +24,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ListenerHolder; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DeleteUnloadableSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DeleteUnloadableSessionTest.java index 076b688835e8..60b1d618305d 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DeleteUnloadableSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DeleteUnloadableSessionTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DuplicateCookieTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DuplicateCookieTest.java index f30bc8b040a3..1f3774f3cfa6 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DuplicateCookieTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/DuplicateCookieTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/IdleSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/IdleSessionTest.java index 47b1268f6d1e..abd89d7df23d 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/IdleSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/IdleSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletContextRequest; import org.eclipse.jetty.ee10.servlet.ServletHolder; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ModifyMaxInactiveIntervalTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ModifyMaxInactiveIntervalTest.java index 9feac27eae26..826fda31c4c3 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ModifyMaxInactiveIntervalTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ModifyMaxInactiveIntervalTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/NonClusteredSessionScavengingTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/NonClusteredSessionScavengingTest.java index e62f106bf1fa..3dd6a50be3ec 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/NonClusteredSessionScavengingTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/NonClusteredSessionScavengingTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RedirectSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RedirectSessionTest.java index 8714d9fee057..03b0a3446613 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RedirectSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RedirectSessionTest.java @@ -20,8 +20,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.SessionCache; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ReentrantRequestSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ReentrantRequestSessionTest.java index 8af1cd0e1062..bf84a9765904 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ReentrantRequestSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/ReentrantRequestSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.NullSessionDataStoreFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RemoveSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RemoveSessionTest.java index 3ace3086fb08..95412636897d 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RemoveSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RemoveSessionTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.SessionHandler; import org.eclipse.jetty.session.AbstractSessionCache; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestDispatchedSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestDispatchedSessionTest.java index 786e1918353f..2adc11cfeac7 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestDispatchedSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestDispatchedSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.FormRequestContent; import org.eclipse.jetty.ee10.servlet.DefaultServlet; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestScopedSessionSaveTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestScopedSessionSaveTest.java index ac7185bc171e..8671bfecaa89 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestScopedSessionSaveTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/RequestScopedSessionSaveTest.java @@ -24,8 +24,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SameContextForwardedSessionTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SameContextForwardedSessionTest.java index 286ebe5ee4ca..1d0fe905b07c 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SameContextForwardedSessionTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SameContextForwardedSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidateCreateScavengeTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidateCreateScavengeTest.java index e4d4fc8b38e5..8f84917c4bfd 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidateCreateScavengeTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidateCreateScavengeTest.java @@ -28,9 +28,9 @@ import jakarta.servlet.http.HttpSessionBindingListener; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidationTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidationTest.java index 80c615fcafb4..644dddadc574 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidationTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionInvalidationTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; diff --git a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionRenewTest.java b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionRenewTest.java index c92cd8c63053..a7182f3d4604 100644 --- a/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionRenewTest.java +++ b/jetty-ee10/test-ee10-sessions/test-ee10-sessions-common/src/test/java/org/eclipse/jetty/ee10/session/SessionRenewTest.java @@ -24,9 +24,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionIdListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletContextRequest; import org.eclipse.jetty.session.DefaultSessionCache; diff --git a/jetty-ee8/jetty-ee8-openid/src/main/config/etc/jetty-ee8-openid.xml b/jetty-ee8/jetty-ee8-openid/src/main/config/etc/jetty-ee8-openid.xml index 60560514ee44..ec0768299f06 100644 --- a/jetty-ee8/jetty-ee8-openid/src/main/config/etc/jetty-ee8-openid.xml +++ b/jetty-ee8/jetty-ee8-openid/src/main/config/etc/jetty-ee8-openid.xml @@ -4,7 +4,7 @@ - + diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-async-rest/jetty-ee9-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee9/demos/AsyncRestServlet.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-async-rest/jetty-ee9-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee9/demos/AsyncRestServlet.java index e8a6972705cb..f438ba020c60 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-async-rest/jetty-ee9-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee9/demos/AsyncRestServlet.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-async-rest/jetty-ee9-demo-async-rest-jar/src/main/java/org/eclipse/jetty/ee9/demos/AsyncRestServlet.java @@ -27,8 +27,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.NanoTime; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/AbstractEmbeddedTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/AbstractEmbeddedTest.java index 02e9d031aca0..ebdc35772fba 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/AbstractEmbeddedTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/AbstractEmbeddedTest.java @@ -13,9 +13,9 @@ package org.eclipse.jetty.ee9.demos; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerTest.java index ee576360ff25..cc90a423d8dc 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerTest.java @@ -15,8 +15,8 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerXmlTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerXmlTest.java index f3b6fc42ea1c..50aaa69c7e4a 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerXmlTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ExampleServerXmlTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FastFileServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FastFileServerTest.java index 307d0613005e..e2a10f0932fe 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FastFileServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FastFileServerTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerTest.java index 81fd0865ad36..725350dceaf8 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerXmlTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerXmlTest.java index 8c97f3d0d481..d777e8726ccc 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerXmlTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/FileServerXmlTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/JarServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/JarServerTest.java index 9f8a57fe4059..81fbb898595f 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/JarServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/JarServerTest.java @@ -19,7 +19,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; @@ -89,4 +89,4 @@ public void testGetDir1Test1() throws Exception String responseBody = response.getContentAsString(); assertThat("Response Content", responseBody, containsString("test1")); } -} \ No newline at end of file +} diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/LikeJettyXmlTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/LikeJettyXmlTest.java index ca58a351571d..964cc549f00d 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/LikeJettyXmlTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/LikeJettyXmlTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyConnectorsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyConnectorsTest.java index bc41dc527c9d..f4bf3a6efb67 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyConnectorsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyConnectorsTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyContextsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyContextsTest.java index e73300253e64..958eccb4594c 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyContextsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyContextsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyHandlersTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyHandlersTest.java index 4f343d82b1ce..420f973a7ff3 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyHandlersTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyHandlersTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Map; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyServletContextsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyServletContextsTest.java index 50b3d528b428..1ed65325d447 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyServletContextsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ManyServletContextsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/MinimalServletsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/MinimalServletsTest.java index 4d2baaf0adc2..e272a4e903d5 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/MinimalServletsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/MinimalServletsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneConnectorTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneConnectorTest.java index 2698f6f8dcae..3c1353b5b50b 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneConnectorTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneConnectorTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneContextTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneContextTest.java index 378c855f28c3..1f8851f7f1e7 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneContextTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneContextTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneHandlerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneHandlerTest.java index 142510f2910d..703c34900e26 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneHandlerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneHandlerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextJmxStatsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextJmxStatsTest.java index a79664f16015..04bfccbb2719 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextJmxStatsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextJmxStatsTest.java @@ -19,7 +19,7 @@ import javax.management.ObjectInstance; import javax.management.ObjectName; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ConnectionStatistics; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextTest.java index 7dfdd749531f..b46dfd28140d 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextTest.java @@ -18,13 +18,12 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; -import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextWithSessionTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextWithSessionTest.java index a77f1f45e8c8..445b0e6b173f 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextWithSessionTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneServletContextWithSessionTest.java @@ -18,7 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppTest.java index 9a61fca955cd..e7506ed2c968 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppWithJspTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppWithJspTest.java index f0733cc15a2a..f242aa3c61a5 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppWithJspTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/OneWebAppWithJspTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ProxyServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ProxyServerTest.java index d61ae56c4566..fc50344ac7d3 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ProxyServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ProxyServerTest.java @@ -15,8 +15,8 @@ import java.net.URI; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/RewriteServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/RewriteServerTest.java index 1f4e13997f20..a991920adb88 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/RewriteServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/RewriteServerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SecuredHelloHandlerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SecuredHelloHandlerTest.java index 2aa76c2cd8b9..f0f13d04a60d 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SecuredHelloHandlerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SecuredHelloHandlerTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.Base64; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithAnnotationsTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithAnnotationsTest.java index 59010874a27d..44a411746afe 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithAnnotationsTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithAnnotationsTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.LifeCycle; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithJNDITest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithJNDITest.java index db9aa44d6602..a17f0cd84798 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithJNDITest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/ServerWithJNDITest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.LifeCycle; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SimplestServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SimplestServerTest.java index 710f887d098e..e7f5abc1a75c 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SimplestServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SimplestServerTest.java @@ -15,7 +15,7 @@ import java.net.URI; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.junit.jupiter.api.AfterEach; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SplitFileServerTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SplitFileServerTest.java index f7d128aee53a..846aef078e56 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SplitFileServerTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/test/java/org/eclipse/jetty/ee9/demos/SplitFileServerTest.java @@ -17,7 +17,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.resource.Resource; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java index 26dc80522bd8..8e82b9ccd55c 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java @@ -18,8 +18,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.webapp.WebAppContext; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AsyncContentProducer.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AsyncContentProducer.java index eb1db66f4f8c..0107299b0e45 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AsyncContentProducer.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/AsyncContentProducer.java @@ -19,9 +19,6 @@ import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.http.Trailers; -import org.eclipse.jetty.io.Content; -import org.eclipse.jetty.server.Response; import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.StaticException; import org.eclipse.jetty.util.component.Destroyable; @@ -36,13 +33,14 @@ class AsyncContentProducer implements ContentProducer { private static final Logger LOG = LoggerFactory.getLogger(AsyncContentProducer.class); - private static final Content.Chunk.Error RECYCLED_ERROR_CONTENT = Content.Chunk.from(new StaticException("ContentProducer has been recycled")); + private static final HttpInput.ErrorContent RECYCLED_ERROR_CONTENT = new HttpInput.ErrorContent(new StaticException("ContentProducer has been recycled")); + private static final Throwable UNCONSUMED_CONTENT_EXCEPTION = new StaticException("Unconsumed content"); private final AutoLock _lock = new AutoLock(); private final HttpChannel _httpChannel; private HttpInput.Interceptor _interceptor; - private Content.Chunk _rawContent; - private Content.Chunk _transformedContent; + private HttpInput.Content _rawContent; + private HttpInput.Content _transformedContent; private boolean _error; private long _firstByteNanoTime = Long.MIN_VALUE; private long _rawContentArrived; @@ -69,12 +67,12 @@ public void recycle() // that asking this instance for content between recycle and reopen will only produce error'ed content. if (_rawContent == null) _rawContent = RECYCLED_ERROR_CONTENT; - else if (!_rawContent.isTerminal()) + else if (!_rawContent.isSpecial()) throw new IllegalStateException("ContentProducer with unconsumed content cannot be recycled"); if (_transformedContent == null) _transformedContent = RECYCLED_ERROR_CONTENT; - else if (!_transformedContent.isTerminal()) + else if (!_transformedContent.isSpecial()) throw new IllegalStateException("ContentProducer with unconsumed content cannot be recycled"); if (_interceptor instanceof Destroyable) @@ -113,7 +111,7 @@ public void setInterceptor(HttpInput.Interceptor interceptor) public int available() { assertLocked(); - Content.Chunk content = nextTransformedContent(); + HttpInput.Content content = nextTransformedContent(); int available = content == null ? 0 : content.remaining(); if (LOG.isDebugEnabled()) LOG.debug("available = {} {}", available, this); @@ -164,7 +162,7 @@ public void checkMinDataRate() LOG.debug("checkMinDataRate aborting channel {}", this); _httpChannel.abort(bad); } - releaseContent(); + failCurrentContent(bad); throw bad; } } @@ -184,50 +182,56 @@ public long getRawContentArrived() public boolean consumeAll() { assertLocked(); - - // release any raw content we have already and check for EOF - boolean eof = releaseContent(); - if (eof) - return true; - - while (true) + Throwable x = UNCONSUMED_CONTENT_EXCEPTION; + if (LOG.isTraceEnabled()) { - _rawContent = _httpChannel.getCoreRequest().read(); - if (_rawContent == null) - return false; - _rawContent.release(); - if (_rawContent.isLast()) - return true; + x = new StaticException("Unconsumed content", true); + LOG.trace("consumeAll {}", this, x); } + failCurrentContent(x); + // A specific HttpChannel mechanism must be used as the following code + // does not guarantee that the channel will synchronously deliver all + // content it already contains: + // while (true) + // { + // HttpInput.Content content = _httpChannel.produceContent(); + // ... + // } + // as the HttpChannel's produceContent() contract makes no such promise; + // for instance the H2 implementation calls Stream.demand() that may + // deliver the content asynchronously. Tests in StreamResetTest cover this. + boolean atEof = _httpChannel.failAllContent(x); + if (LOG.isDebugEnabled()) + LOG.debug("failed all content of http channel EOF={} {}", atEof, this); + return atEof; } - @Override - public boolean releaseContent() + private void failCurrentContent(Throwable x) { - assertLocked(); - - // release transformed content, ignoring any unconsumed. - if (_transformedContent != null && !_transformedContent.isTerminal()) + if (_transformedContent != null && !_transformedContent.isSpecial()) { if (_transformedContent != _rawContent) { if (LOG.isDebugEnabled()) - LOG.debug("failing currently held transformed content {} {}", null, this); + LOG.debug("failing currently held transformed content {} {}", x, this); _transformedContent.skip(_transformedContent.remaining()); - _transformedContent.release(); + _transformedContent.failed(x); } _transformedContent = null; } - if (_rawContent != null && !_rawContent.isTerminal()) + if (_rawContent != null && !_rawContent.isSpecial()) { if (LOG.isDebugEnabled()) - LOG.debug("failing currently held raw content {} {}", null, this); - _rawContent.release(); - _rawContent = _rawContent.isLast() ? Content.Chunk.EOF : null; + LOG.debug("failing currently held raw content {} {}", x, this); + _rawContent.skip(_rawContent.remaining()); + _rawContent.failed(x); + _rawContent = null; } - return _rawContent != null && _rawContent.isLast(); + HttpInput.ErrorContent errorContent = new HttpInput.ErrorContent(x); + _transformedContent = errorContent; + _rawContent = errorContent; } @Override @@ -240,10 +244,10 @@ public boolean onContentProducible() } @Override - public Content.Chunk nextContent() + public HttpInput.Content nextContent() { assertLocked(); - Content.Chunk content = nextTransformedContent(); + HttpInput.Content content = nextTransformedContent(); if (LOG.isDebugEnabled()) LOG.debug("nextContent = {} {}", content, this); if (content != null) @@ -252,14 +256,14 @@ public Content.Chunk nextContent() } @Override - public void reclaim(Content.Chunk content) + public void reclaim(HttpInput.Content content) { assertLocked(); if (LOG.isDebugEnabled()) LOG.debug("reclaim {} {}", content, this); if (_transformedContent == content) { - content.release(); + content.succeeded(); if (_transformedContent == _rawContent) _rawContent = null; _transformedContent = null; @@ -270,7 +274,7 @@ public void reclaim(Content.Chunk content) public boolean isReady() { assertLocked(); - Content.Chunk content = nextTransformedContent(); + HttpInput.Content content = nextTransformedContent(); if (content != null) { if (LOG.isDebugEnabled()) @@ -279,12 +283,25 @@ public boolean isReady() } _httpChannel.getState().onReadUnready(); - _httpChannel.getCoreRequest().demand(() -> + while (_httpChannel.needContent()) { - if (_httpChannel.getRequest().getHttpInput().onContentProducible()) - _httpChannel.handle(); - }); - + content = nextTransformedContent(); + if (LOG.isDebugEnabled()) + LOG.debug("isReady(), got transformed content after needContent retry {} {}", content, this); + if (content != null) + { + _httpChannel.getState().onContentAdded(); + return true; + } + else + { + // We could have read some rawContent but not enough to generate + // transformed content, so we need to call needContent() again + // to tell the channel that more content is needed. + if (LOG.isDebugEnabled()) + LOG.debug("isReady(), could not transform content after needContent retry {}", this); + } + } if (LOG.isDebugEnabled()) LOG.debug("isReady(), no content for needContent retry {}", this); return false; @@ -295,7 +312,7 @@ boolean isUnready() return _httpChannel.getState().isInputUnready(); } - private Content.Chunk nextTransformedContent() + private HttpInput.Content nextTransformedContent() { if (LOG.isDebugEnabled()) LOG.debug("nextTransformedContent {}", this); @@ -304,19 +321,18 @@ private Content.Chunk nextTransformedContent() { if (_transformedContent != null) { - if (_transformedContent.isTerminal() || _transformedContent.hasRemaining()) + if (_transformedContent.isSpecial() || !_transformedContent.isEmpty()) { - if (_transformedContent instanceof Content.Chunk.Error && !_error) + if (_transformedContent.getError() != null && !_error) { // In case the _rawContent was set by consumeAll(), check the httpChannel // to see if it has a more precise error. Otherwise, the exact same // special content will be returned by the httpChannel; do not do that // if the _error flag was set, meaning the current error is definitive. - Content.Chunk refreshedRawContent = produceRawContent(); + HttpInput.Content refreshedRawContent = produceRawContent(); if (refreshedRawContent != null) _rawContent = _transformedContent = refreshedRawContent; - _error = _rawContent instanceof Content.Chunk.Error; - + _error = _rawContent.getError() != null; if (LOG.isDebugEnabled()) LOG.debug("refreshed raw content: {} {}", _rawContent, this); } @@ -329,8 +345,7 @@ private Content.Chunk nextTransformedContent() { if (LOG.isDebugEnabled()) LOG.debug("current transformed content depleted {}", this); - - _transformedContent.release(); + _transformedContent.succeeded(); _transformedContent = null; } } @@ -363,42 +378,42 @@ private void transformRawContent() _transformedContent = intercept(); // If the interceptor generated a special content, _rawContent must become that special content. - if (_transformedContent != null && _transformedContent.isTerminal() && _transformedContent != _rawContent) + if (_transformedContent != null && _transformedContent.isSpecial() && _transformedContent != _rawContent) { if (LOG.isDebugEnabled()) LOG.debug("interceptor generated a special content, _rawContent must become that special content {}", this); - _rawContent.release(); + _rawContent.succeeded(); _rawContent = _transformedContent; return; } // If the interceptor generated a null content, recycle the raw content now if it is empty. - if (_transformedContent == null && !_rawContent.hasRemaining() && !_rawContent.isTerminal()) + if (_transformedContent == null && _rawContent.isEmpty() && !_rawContent.isSpecial()) { if (LOG.isDebugEnabled()) LOG.debug("interceptor generated a null content, recycling the empty raw content now {}", this); - _rawContent.release(); + _rawContent.succeeded(); _rawContent = null; return; } // If the interceptor returned the raw content, recycle the raw content now if it is empty. - if (_transformedContent == _rawContent && !_rawContent.hasRemaining() && !_rawContent.isTerminal()) + if (_transformedContent == _rawContent && _rawContent.isEmpty() && !_rawContent.isSpecial()) { if (LOG.isDebugEnabled()) LOG.debug("interceptor returned the raw content, recycle the empty raw content now {}", this); - _rawContent.release(); + _rawContent.succeeded(); _rawContent = _transformedContent = null; } } else { // Recycle the raw content now if it is empty. - if (!_rawContent.hasRemaining() && !_rawContent.isTerminal()) + if (_rawContent.isEmpty() && !_rawContent.isSpecial()) { if (LOG.isDebugEnabled()) LOG.debug("recycling the empty raw content now {}", this); - _rawContent.release(); + _rawContent.succeeded(); _rawContent = null; } @@ -408,39 +423,39 @@ private void transformRawContent() } } - private Content.Chunk intercept() + private HttpInput.Content intercept() { try { int remainingBeforeInterception = _rawContent.remaining(); - Content.Chunk content = _interceptor.readFrom(_rawContent); - if (content != null && content.isTerminal() && !_rawContent.isTerminal()) + HttpInput.Content content = _interceptor.readFrom(_rawContent); + if (content != null && content.isSpecial() && !_rawContent.isSpecial()) { - if (content instanceof Content.Chunk.Error errorContent) + Throwable error = content.getError(); + if (error != null) { // Set the _error flag to mark the content as definitive, i.e.: // do not try to produce new raw content to get a fresher error // when the special content was generated by the interceptor. _error = true; if (_httpChannel.getResponse().isCommitted()) - _httpChannel.abort(errorContent.getCause()); + _httpChannel.abort(error); } - if (LOG.isDebugEnabled()) LOG.debug("interceptor generated special content {}", this); } - else if (content != _rawContent && !_rawContent.isTerminal() && _rawContent.hasRemaining() && _rawContent.remaining() == remainingBeforeInterception) + else if (content != _rawContent && !_rawContent.isSpecial() && !_rawContent.isEmpty() && _rawContent.remaining() == remainingBeforeInterception) { IOException failure = new IOException("Interceptor " + _interceptor + " did not consume any of the " + _rawContent.remaining() + " remaining byte(s) of content"); if (content != null) - content.release(); - releaseContent(); + content.failed(failure); + failCurrentContent(failure); // Set the _error flag to mark the content as definitive, i.e.: // do not try to produce new raw content to get a fresher error // when the special content was caused by the interceptor not // consuming the raw content. _error = true; - org.eclipse.jetty.server.Response response = _httpChannel.getCoreResponse(); + Response response = _httpChannel.getResponse(); if (response.isCommitted()) _httpChannel.abort(failure); if (LOG.isDebugEnabled()) @@ -455,12 +470,12 @@ else if (content != _rawContent && !_rawContent.isTerminal() && _rawContent.hasR catch (Throwable x) { IOException failure = new IOException("Bad content", x); - releaseContent(); + failCurrentContent(failure); // Set the _error flag to mark the content as definitive, i.e.: // do not try to produce new raw content to get a fresher error // when the special content was caused by the interceptor throwing. _error = true; - Response response = _httpChannel.getCoreResponse(); + Response response = _httpChannel.getResponse(); if (response.isCommitted()) _httpChannel.abort(failure); if (LOG.isDebugEnabled()) @@ -469,9 +484,9 @@ else if (content != _rawContent && !_rawContent.isTerminal() && _rawContent.hasR } } - private Content.Chunk produceRawContent() + private HttpInput.Content produceRawContent() { - Content.Chunk content = _httpChannel.getCoreRequest().read(); + HttpInput.Content content = _httpChannel.produceContent(); if (content != null) { _rawContentArrived += content.remaining(); @@ -479,14 +494,6 @@ private Content.Chunk produceRawContent() _firstByteNanoTime = NanoTime.now(); if (LOG.isDebugEnabled()) LOG.debug("produceRawContent updated rawContentArrived to {} and firstByteTimeStamp to {} {}", _rawContentArrived, _firstByteNanoTime, this); - - // TODO do we really need these listeners? - if (content.hasRemaining()) - _httpChannel.onContent(content); - if (content instanceof Trailers trailers) - _httpChannel.onTrailers(trailers.getTrailers()); - if (content.isLast()) - _httpChannel.onContentComplete(); } if (LOG.isDebugEnabled()) LOG.debug("produceRawContent produced {} {}", content, this); @@ -502,13 +509,14 @@ private void assertLocked() @Override public String toString() { - return String.format("%s@%x[r=%s,t=%s,i=%s,error=%b]", + return String.format("%s@%x[r=%s,t=%s,i=%s,error=%b,c=%s]", getClass().getSimpleName(), hashCode(), _rawContent, _transformedContent, _interceptor, - _error + _error, + _httpChannel ); } diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/BlockingContentProducer.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/BlockingContentProducer.java index 78ed81aecbc4..effce5560422 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/BlockingContentProducer.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/BlockingContentProducer.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.ee9.nested; -import org.eclipse.jetty.io.Content; import org.eclipse.jetty.util.thread.AutoLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -97,19 +96,11 @@ public boolean consumeAll() } @Override - public boolean releaseContent() - { - boolean eof = _asyncContentProducer.releaseContent(); - _semaphore.release(); - return eof; - } - - @Override - public Content.Chunk nextContent() + public HttpInput.Content nextContent() { while (true) { - Content.Chunk content = _asyncContentProducer.nextContent(); + HttpInput.Content content = _asyncContentProducer.nextContent(); if (LOG.isDebugEnabled()) LOG.debug("nextContent async producer returned {}", content); if (content != null) @@ -132,13 +123,13 @@ public Content.Chunk nextContent() } catch (InterruptedException e) { - return Content.Chunk.from(e); + return new HttpInput.ErrorContent(e); } } } @Override - public void reclaim(Content.Chunk content) + public void reclaim(HttpInput.Content content) { _asyncContentProducer.reclaim(content); } diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContentProducer.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContentProducer.java index 711c18a388ec..43c6101a9eaf 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContentProducer.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContentProducer.java @@ -14,7 +14,6 @@ package org.eclipse.jetty.ee9.nested; import org.eclipse.jetty.io.Content; -import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.thread.AutoLock; @@ -42,23 +41,15 @@ public interface ContentProducer */ void reopen(); - /** - * Consume all content currently available in this {@link ContentProducer} instance - * as well as in the underlying {@link HttpChannel}. + * Consumes all content currently available in this {@link ContentProducer} instance + * as well as in the underlying {@link Content.Source}. * * This call is always non-blocking. * @return true if EOF was reached. */ boolean consumeAll(); - /** - * Release any held content. - * - * @return true if EOF seen. - */ - boolean releaseContent(); - /** * Check if the current data rate consumption is above the minimal rate. * Abort the channel, fail the content currently available and throw a @@ -116,13 +107,13 @@ public interface ContentProducer * @return the next content that can be read from or null if the implementation does not block * and has no available content. */ - Content.Chunk nextContent(); + HttpInput.Content nextContent(); /** - * Free up the content by calling {@link Content.Chunk#release()} on it + * Free up the content by calling {@link HttpInput.Content#succeeded()} on it * and updating this instance' internal state. */ - void reclaim(Content.Chunk content); + void reclaim(HttpInput.Content content); /** * Check if this {@link ContentProducer} instance has some content that can be read without blocking. diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannel.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannel.java index d07d7b240192..dc1fae1ab269 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannel.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannel.java @@ -42,6 +42,7 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.MetaData; +import org.eclipse.jetty.http.Trailers; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Content; @@ -139,6 +140,72 @@ public ConnectionMetaData getConnectionMetaData() return _connectionMetaData; } + /** + * Notify the channel that content is needed. If some content is immediately available, true is returned and + * {@link #produceContent()} has to be called and will return a non-null object. + * If no content is immediately available, an attempt to produce content must be made; if new content has been + * produced, true is returned; otherwise {@link HttpInput#onContentProducible()} is called once some content + * arrives and {@link #produceContent()} can be called without returning {@code null}. + * If a failure happens, then {@link HttpInput#onContentProducible()} will be called and an error content will + * return the error on the next call to {@link #produceContent()}. + * @return true if content is immediately available. + */ + public boolean needContent() + { + // TODO: optimize by attempting a read? + getCoreRequest().demand(() -> + { + if (getRequest().getHttpInput().onContentProducible()) + handle(); + }); + return false; + } + + /** + * Produce a {@link HttpInput.Content} object with data currently stored within the channel. The produced content + * can be special (meaning calling {@link HttpInput.Content#isSpecial()} returns true) if the channel reached a special + * state, like EOF or an error. + * Once a special content has been returned, all subsequent calls to this method will always return a special content + * of the same kind and {@link #needContent()} will always return true. + * The returned content is "raw", i.e.: not decoded. + * @return a {@link HttpInput.Content} object if one is immediately available without blocking, null otherwise. + */ + public HttpInput.Content produceContent() + { + Content.Chunk chunk = getCoreRequest().read(); + if (chunk == null) + return null; + + if (chunk.hasRemaining()) + onContent(chunk); + if (chunk instanceof Trailers trailers) + onTrailers(trailers.getTrailers()); + if (chunk.isLast()) + onContentComplete(); + + return HttpInput.Content.asChunk(chunk); + } + + /** + * Fail all content that is currently stored within the channel. + * @param failure the failure to fail the content with. + * @return true if EOF was reached while failing all content, false otherwise. + */ + public boolean failAllContent(Throwable failure) + { + while (true) + { + HttpInput.Content content = produceContent(); + if (content == null) + return false; + if (content.isSpecial()) + return content.isEof(); + content.failed(failure); + if (content.isEof()) + return true; + } + } + /** * Fail the channel's input. * @param failure the failure. @@ -898,7 +965,7 @@ void onContent(Content.Chunk content) { if (LOG.isDebugEnabled()) LOG.debug("onContent {} {}", this, content); - _combinedListener.onRequestContent(_request, content.getByteBuffer()); + _combinedListener.onRequestContent(_request, content.getByteBuffer().slice()); } void onContentComplete() diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpInput.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpInput.java index c78a26bd63e7..44477119c695 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpInput.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpInput.java @@ -21,8 +21,8 @@ import jakarta.servlet.ReadListener; import jakarta.servlet.ServletInputStream; import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.Context; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.thread.AutoLock; @@ -37,10 +37,10 @@ public class HttpInput extends ServletInputStream implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(HttpInput.class); - private final HttpChannel _httpChannel; private final byte[] _oneByteBuffer = new byte[1]; - private BlockingContentProducer _blockingContentProducer; - private AsyncContentProducer _asyncContentProducer; + private final BlockingContentProducer _blockingContentProducer; + private final AsyncContentProducer _asyncContentProducer; + private final HttpChannel _httpChannel; private final LongAdder _contentConsumed = new LongAdder(); private volatile ContentProducer _contentProducer; private volatile boolean _consumedEof; @@ -131,18 +131,18 @@ public void addInterceptor(Interceptor interceptor) } } - private int get(Content.Chunk chunk, byte[] bytes, int offset, int length) + private int get(Content content, byte[] bytes, int offset, int length) { - length = Math.min(chunk.remaining(), length); - chunk.getByteBuffer().get(bytes, offset, length); - _contentConsumed.add(length); - return length; + length = Math.min(content.remaining(), length); + int consumed = content.get(bytes, offset, length); + _contentConsumed.add(consumed); + return consumed; } - private int get(Content.Chunk chunk, ByteBuffer des) + private int get(Content content, ByteBuffer des) { var capacity = des.remaining(); - var src = chunk.getByteBuffer(); + var src = content.getByteBuffer(); if (src.remaining() > capacity) { int limit = src.limit(); @@ -172,18 +172,6 @@ public long getContentReceived() } } - public void releaseContent() - { - try (AutoLock lock = _contentProducer.lock()) - { - if (LOG.isDebugEnabled()) - LOG.debug("consumeAll {}", this); - boolean eof = _contentProducer.releaseContent(); - if (eof) - _consumedEof = true; - } - } - public boolean consumeAll() { try (AutoLock lock = _contentProducer.lock()) @@ -302,22 +290,32 @@ private int read(ByteBuffer buffer, byte[] b, int off, int len) throws IOExcepti // Calculate minimum request rate for DoS protection _contentProducer.checkMinDataRate(); - Content.Chunk content = _contentProducer.nextContent(); + Content content = _contentProducer.nextContent(); if (content == null) throw new IllegalStateException("read on unready input"); + + if (!content.isSpecial()) + { + int read = buffer == null ? get(content, b, off, len) : get(content, buffer); + if (LOG.isDebugEnabled()) + LOG.debug("read produced {} byte(s) {}", read, this); + if (content.isEmpty()) + _contentProducer.reclaim(content); + return read; + } - if (content.isTerminal()) + Throwable error = content.getError(); + if (LOG.isDebugEnabled()) + LOG.debug("read error={} {}", error, this); + if (error != null) { - if (content instanceof Content.Chunk.Error errorContent) - { - Throwable error = errorContent.getCause(); - if (LOG.isDebugEnabled()) - LOG.debug("read error={} {}", error, this); - if (error instanceof IOException) - throw (IOException)error; - throw new IOException(error); - } + if (error instanceof IOException) + throw (IOException)error; + throw new IOException(error); + } + if (content.isEof()) + { if (LOG.isDebugEnabled()) LOG.debug("read at EOF, setting consumed EOF to true {}", this); _consumedEof = true; @@ -326,15 +324,8 @@ private int read(ByteBuffer buffer, byte[] b, int off, int len) throws IOExcepti scheduleReadListenerNotification(); return -1; } - else - { - int read = buffer == null ? get(content, b, off, len) : get(content, buffer); - if (LOG.isDebugEnabled()) - LOG.debug("read produced {} byte(s) {}", read, this); - if (!content.hasRemaining()) - _contentProducer.reclaim(content); - return read; - } + + throw new AssertionError("no data, no error and not EOF"); } } @@ -382,7 +373,7 @@ public int available() @Override public void run() { - Content.Chunk content; + Content content; try (AutoLock lock = _contentProducer.lock()) { // Call isReady() to make sure that if not ready we register for fill interest. @@ -406,18 +397,18 @@ public void run() return; } - if (content.isTerminal()) + if (content.isSpecial()) { - if (content instanceof Content.Chunk.Error errorContent) + Throwable error = content.getError(); + if (error != null) { - Throwable error = errorContent.getCause(); if (LOG.isDebugEnabled()) LOG.debug("running error={} {}", error, this); // TODO is this necessary to add here? _httpChannel.getResponse().getHttpFields().add(HttpFields.CONNECTION_CLOSE); _readListener.onError(error); } - else + else if (content.isEof()) { try { @@ -460,9 +451,9 @@ public String toString() } /** - *

{@link Content.Chunk} interceptor that can be registered using {@link #setInterceptor(Interceptor)} or + *

{@link Content} interceptor that can be registered using {@link #setInterceptor(Interceptor)} or * {@link #addInterceptor(Interceptor)}. - * When {@link Content.Chunk} instances are generated, they are passed to the registered interceptor (if any) + * When {@link Content} instances are generated, they are passed to the registered interceptor (if any) * that is then responsible for providing the actual content that is consumed by {@link #read(byte[], int, int)} and its * sibling methods.

* A minimal implementation could be as simple as: @@ -487,21 +478,24 @@ public String toString() * * Implementors of this interface must keep the following in mind: *
    - *
  • Calling {@link Content.Chunk#getByteBuffer()} when {@link Content.Chunk#isTerminal()} returns true throws + *
  • Calling {@link Content#getByteBuffer()} when {@link Content#isSpecial()} returns true throws * {@link IllegalStateException}.
  • - *
  • A {@link Content.Chunk} can both be non-special and have {@code content == Content.EOF} return true.
  • - *
  • {@link Content.Chunk} extends {@link Callback} to manage the lifecycle of the contained byte buffer. The code calling - * {@link #readFrom(Content.Chunk)} is responsible for managing the lifecycle of both the passed and the returned content - * instances, once {@link ByteBuffer#hasRemaining()} returns false {@code HttpInput} will make sure + *
  • A {@link Content} can both be non-special and have {@link Content#isEof()} return true.
  • + *
  • {@link Content} extends {@link Callback} to manage the lifecycle of the contained byte buffer. The code calling + * {@link #readFrom(Content)} is responsible for managing the lifecycle of both the passed and the returned content + * instances, once {@link ByteBuffer#hasRemaining()} returns false {@link HttpInput} will make sure * {@link Callback#succeeded()} is called, or {@link Callback#failed(Throwable)} if an error occurs.
  • - *
  • After {@link #readFrom(Content.Chunk)} is called for the first time, subsequent {@link #readFrom(Content.Chunk)} calls will + *
  • After {@link #readFrom(Content)} is called for the first time, subsequent {@link #readFrom(Content)} calls will * occur only after the contained byte buffer is empty (see above) or at any time if the returned content was special.
  • - *
  • Once {@link #readFrom(Content.Chunk)} returned a special content, subsequent calls to {@link #readFrom(Content.Chunk)} must + *
  • Once {@link #readFrom(Content)} returned a special content, subsequent calls to {@link #readFrom(Content)} must * always return the same special content.
  • *
  • Implementations implementing both this interface and {@link Destroyable} will have their * {@link Destroyable#destroy()} method called when {@link #recycle()} is called.
  • *
+ * + * @deprecated Interceptor has been removed with no replacement in the EE10 implementation */ + @Deprecated(forRemoval = true) public interface Interceptor { /** @@ -511,13 +505,13 @@ public interface Interceptor * unless the returned content is the passed content instance. * @return The intercepted content or null if interception is completed for that content. */ - Content.Chunk readFrom(Content.Chunk content); + Content readFrom(Content content); } /** * An {@link Interceptor} that chains two other {@link Interceptor}s together. - * The {@link Interceptor#readFrom(Content.Chunk)} calls the previous {@link Interceptor}'s - * {@link Interceptor#readFrom(Content.Chunk)} and then passes any {@link Content.Chunk} returned + * The {@link Interceptor#readFrom(Content)} calls the previous {@link Interceptor}'s + * {@link Interceptor#readFrom(Content)} and then passes any {@link Content} returned * to the next {@link Interceptor}. */ private static class ChainedInterceptor implements Interceptor, Destroyable @@ -542,9 +536,9 @@ Interceptor getNext() } @Override - public Content.Chunk readFrom(Content.Chunk content) + public Content readFrom(Content content) { - Content.Chunk c = getPrev().readFrom(content); + Content c = getPrev().readFrom(content); if (c == null) return null; return getNext().readFrom(c); @@ -565,4 +559,293 @@ public String toString() return getClass().getSimpleName() + "@" + hashCode() + " [p=" + _prev + ",n=" + _next + "]"; } } + + /** + * A content represents the production of context bytes by {@link AsyncContentProducer#nextContent()}. + * There are two fundamental types of content: special and non-special. + * Non-special content always wraps a byte buffer that can be consumed and must be recycled once it is empty, either + * via {@link #succeeded()} or {@link #failed(Throwable)}. + * Special content indicates a special event, like EOF or an error and never wraps a byte buffer. Calling + * {@link #succeeded()} or {@link #failed(Throwable)} on those have no effect. + */ + public static class Content implements Callback + { + public static Content asChunk(org.eclipse.jetty.io.Content.Chunk chunk) + { + if (chunk instanceof org.eclipse.jetty.io.Content.Chunk.Error error) + return new ErrorContent(error.getCause()); + if (chunk.isLast() && !chunk.hasRemaining()) + return new EofContent(); + Content content = new Content(chunk.getByteBuffer()) + { + @Override + public void succeeded() + { + chunk.release(); + super.succeeded(); + } + + @Override + public void failed(Throwable x) + { + chunk.release(); + super.failed(x); + } + }; + return chunk.isLast() ? new WrappingContent(content, true) : content; + } + + protected final ByteBuffer _content; + + public Content(ByteBuffer content) + { + _content = content; + } + + /** + * Get the wrapped byte buffer. Throws {@link IllegalStateException} if the content is special. + * @return the wrapped byte buffer. + */ + public ByteBuffer getByteBuffer() + { + return _content; + } + + @Override + public InvocationType getInvocationType() + { + return InvocationType.NON_BLOCKING; + } + + /** + * Read the wrapped byte buffer. Throws {@link IllegalStateException} if the content is special. + * @param buffer The array into which bytes are to be written. + * @param offset The offset within the array of the first byte to be written. + * @param length The maximum number of bytes to be written to the given array. + * @return The amount of bytes read from the buffer. + */ + public int get(byte[] buffer, int offset, int length) + { + length = Math.min(_content.remaining(), length); + _content.get(buffer, offset, length); + return length; + } + + /** + * Skip some bytes from the buffer. Has no effect on a special content. + * @param length How many bytes to skip. + * @return How many bytes were skipped. + */ + public int skip(int length) + { + length = Math.min(_content.remaining(), length); + _content.position(_content.position() + length); + return length; + } + + /** + * Check if there is at least one byte left in the buffer. + * Always false on a special content. + * @return true if there is at least one byte left in the buffer. + */ + public boolean hasContent() + { + return _content.hasRemaining(); + } + + /** + * Get the number of bytes remaining in the buffer. + * Always 0 on a special content. + * @return the number of bytes remaining in the buffer. + */ + public int remaining() + { + return _content.remaining(); + } + + /** + * Check if the buffer is empty. + * Always true on a special content. + * @return true if there is 0 byte left in the buffer. + */ + public boolean isEmpty() + { + return !_content.hasRemaining(); + } + + /** + * Check if the content is special. A content is deemed special + * if it does not hold bytes but rather conveys a special event, + * like when EOF has been reached or an error has occurred. + * @return true if the content is special, false otherwise. + */ + public boolean isSpecial() + { + return false; + } + + /** + * Check if EOF was reached. Both special and non-special content + * can have this flag set to true but in the case of non-special content, + * this can be interpreted as a hint as it is always going to be followed + * by another content that is both special and EOF. + * @return true if EOF was reached, false otherwise. + */ + public boolean isEof() + { + return false; + } + + /** + * Get the reported error. Only special contents can have an error. + * @return the error or null if there is none. + */ + public Throwable getError() + { + return null; + } + + @Override + public String toString() + { + return String.format("%s@%x{%s,spc=%s,eof=%s,err=%s}", getClass().getSimpleName(), hashCode(), + BufferUtil.toDetailString(_content), isSpecial(), isEof(), getError()); + } + } + + /** + * Simple non-special content wrapper allow overriding the EOF flag. + */ + public static class WrappingContent extends Content + { + private final Content _delegate; + private final boolean _eof; + + public WrappingContent(Content delegate, boolean eof) + { + super(delegate.getByteBuffer()); + _delegate = delegate; + _eof = eof; + } + + @Override + public boolean isEof() + { + return _eof; + } + + @Override + public void succeeded() + { + _delegate.succeeded(); + } + + @Override + public void failed(Throwable x) + { + _delegate.failed(x); + } + + @Override + public InvocationType getInvocationType() + { + return _delegate.getInvocationType(); + } + } + + /** + * Abstract class that implements the standard special content behavior. + */ + public abstract static class SpecialContent extends Content + { + public SpecialContent() + { + super(null); + } + + @Override + public final ByteBuffer getByteBuffer() + { + throw new IllegalStateException(this + " has no buffer"); + } + + @Override + public final int get(byte[] buffer, int offset, int length) + { + throw new IllegalStateException(this + " has no buffer"); + } + + @Override + public final int skip(int length) + { + return 0; + } + + @Override + public final boolean hasContent() + { + return false; + } + + @Override + public final int remaining() + { + return 0; + } + + @Override + public final boolean isEmpty() + { + return true; + } + + @Override + public final boolean isSpecial() + { + return true; + } + } + + /** + * EOF special content. + */ + public static final class EofContent extends SpecialContent + { + @Override + public boolean isEof() + { + return true; + } + + @Override + public String toString() + { + return getClass().getSimpleName(); + } + } + + /** + * Error special content. + */ + public static final class ErrorContent extends SpecialContent + { + private final Throwable _error; + + public ErrorContent(Throwable error) + { + _error = error; + } + + @Override + public Throwable getError() + { + return _error; + } + + @Override + public String toString() + { + return getClass().getSimpleName() + " [" + _error + "]"; + } + } } diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java index e63daeaccf03..b1c0db6bc00d 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java @@ -1305,9 +1305,10 @@ public String changeSessionId() */ public void onCompleted() { - _input.releaseContent(); + // Clean up unread content. + _input.consumeAll(); - //Clean up any tmp files created by MultiPartInputStream + // Clean up any tmp files created by MultiPartInputStream. if (_multiParts != null) { try diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/AsyncContentProducerTest.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/AsyncContentProducerTest.java index 08cbaa8c4943..a8f1b49e5919 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/AsyncContentProducerTest.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/AsyncContentProducerTest.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; @@ -30,15 +29,14 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.thread.AutoLock; +import org.eclipse.jetty.util.thread.Scheduler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -47,7 +45,6 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -@Disabled // TODO public class AsyncContentProducerTest { private Server _server; @@ -65,6 +62,7 @@ public void setUp() throws Exception _server.setHandler(_contextHandler); _testHandler = new TestHandler(); _contextHandler.setHandler(_testHandler); + _server.start(); } @AfterEach @@ -101,7 +99,7 @@ public void testAsyncContentProducerNoInterceptor() throws Exception CyclicBarrier barrier = new CyclicBarrier(2); - ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, Content.Chunk.EOF, null, barrier)); + ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, new HttpInput.EofContent(), _connector.getScheduler(), barrier)); try (AutoLock ignored = contentProducer.lock()) { @@ -123,7 +121,7 @@ public void testAsyncContentProducerNoInterceptorWithError() throws Exception CyclicBarrier barrier = new CyclicBarrier(2); - ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, Content.Chunk.from(expectedError), null, barrier)); + ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, new HttpInput.ErrorContent(expectedError), _connector.getScheduler(), barrier)); try (AutoLock ignored = contentProducer.lock()) { @@ -144,7 +142,7 @@ public void testAsyncContentProducerEofContentIsPassedToInterceptor() throws Exc CyclicBarrier barrier = new CyclicBarrier(2); - ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, Content.Chunk.EOF, null, barrier)); + ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, new HttpInput.EofContent(), _connector.getScheduler(), barrier)); AccountingInterceptor interceptor = new AccountingInterceptor(); try (AutoLock ignored = contentProducer.lock()) { @@ -153,17 +151,17 @@ public void testAsyncContentProducerEofContentIsPassedToInterceptor() throws Exc Throwable error = readAndAssertContent(totalContentBytesCount, originalContentString, contentProducer, (buffers.length + 1) * 2, 0, 4, barrier); assertThat(error, nullValue()); - Content.Chunk lastContent = contentProducer.nextContent(); - assertThat(lastContent.isTerminal(), is(true)); - assertThat(lastContent.isLast(), is(true)); + HttpInput.Content lastContent = contentProducer.nextContent(); + assertThat(lastContent.isSpecial(), is(true)); + assertThat(lastContent.isEof(), is(true)); } assertThat(interceptor.contents.size(), is(4)); - assertThat(interceptor.contents.get(0).isTerminal(), is(false)); - assertThat(interceptor.contents.get(1).isTerminal(), is(false)); - assertThat(interceptor.contents.get(2).isTerminal(), is(false)); - assertThat(interceptor.contents.get(3).isTerminal(), is(true)); - assertThat(interceptor.contents.get(3).isLast(), is(true)); + assertThat(interceptor.contents.get(0).isSpecial(), is(false)); + assertThat(interceptor.contents.get(1).isSpecial(), is(false)); + assertThat(interceptor.contents.get(2).isSpecial(), is(false)); + assertThat(interceptor.contents.get(3).isSpecial(), is(true)); + assertThat(interceptor.contents.get(3).isEof(), is(true)); } @Test @@ -178,7 +176,7 @@ public void testAsyncContentProducerErrorContentIsPassedToInterceptor() throws E CyclicBarrier barrier = new CyclicBarrier(2); - ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, Content.Chunk.from(new Throwable("testAsyncContentProducerErrorContentIsPassedToInterceptor error")), null, barrier)); + ContentProducer contentProducer = new AsyncContentProducer(new ArrayDelayedHttpChannel(buffers, new HttpInput.ErrorContent(new Throwable("testAsyncContentProducerErrorContentIsPassedToInterceptor error")), _connector.getScheduler(), barrier)); AccountingInterceptor interceptor = new AccountingInterceptor(); try (AutoLock ignored = contentProducer.lock()) { @@ -187,70 +185,91 @@ public void testAsyncContentProducerErrorContentIsPassedToInterceptor() throws E Throwable error = readAndAssertContent(totalContentBytesCount, originalContentString, contentProducer, (buffers.length + 1) * 2, 0, 4, barrier); assertThat(error.getMessage(), is("testAsyncContentProducerErrorContentIsPassedToInterceptor error")); - Content.Chunk lastContent = contentProducer.nextContent(); - assertThat(lastContent.isTerminal(), is(true)); - assertThat(getError(lastContent).getMessage(), is("testAsyncContentProducerErrorContentIsPassedToInterceptor error")); + HttpInput.Content lastContent = contentProducer.nextContent(); + assertThat(lastContent.isSpecial(), is(true)); + assertThat(lastContent.getError().getMessage(), is("testAsyncContentProducerErrorContentIsPassedToInterceptor error")); } assertThat(interceptor.contents.size(), is(4)); - assertThat(interceptor.contents.get(0).isTerminal(), is(false)); - assertThat(interceptor.contents.get(1).isTerminal(), is(false)); - assertThat(interceptor.contents.get(2).isTerminal(), is(false)); - assertThat(interceptor.contents.get(3).isTerminal(), is(true)); - assertThat(getError(interceptor.contents.get(3)).getMessage(), is("testAsyncContentProducerErrorContentIsPassedToInterceptor error")); + assertThat(interceptor.contents.get(0).isSpecial(), is(false)); + assertThat(interceptor.contents.get(1).isSpecial(), is(false)); + assertThat(interceptor.contents.get(2).isSpecial(), is(false)); + assertThat(interceptor.contents.get(3).isSpecial(), is(true)); + assertThat(interceptor.contents.get(3).getError().getMessage(), is("testAsyncContentProducerErrorContentIsPassedToInterceptor error")); } @Test public void testAsyncContentProducerInterceptorGeneratesError() { - AtomicInteger contentReleasedCount = new AtomicInteger(); - ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(Content.Chunk.from(ByteBuffer.allocate(1), false)), Content.Chunk.EOF)); + AtomicInteger contentSucceededCount = new AtomicInteger(); + ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }), new HttpInput.EofContent())); try (AutoLock ignored = contentProducer.lock()) { - contentProducer.setInterceptor(content -> Content.Chunk.from(new Throwable("testAsyncContentProducerInterceptorGeneratesError interceptor error"))); + contentProducer.setInterceptor(content -> new HttpInput.ErrorContent(new Throwable("testAsyncContentProducerInterceptorGeneratesError interceptor error"))); assertThat(contentProducer.isReady(), is(true)); assertThat(contentProducer.isError(), is(true)); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getMessage(), is("testAsyncContentProducerInterceptorGeneratesError interceptor error")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getMessage(), is("testAsyncContentProducerInterceptorGeneratesError interceptor error")); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getMessage(), is("testAsyncContentProducerInterceptorGeneratesError interceptor error")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getMessage(), is("testAsyncContentProducerInterceptorGeneratesError interceptor error")); } - assertThat(contentReleasedCount.get(), is(1)); + assertThat(contentSucceededCount.get(), is(1)); } @Test public void testAsyncContentProducerInterceptorGeneratesEof() { - AtomicInteger contentReleasedCount = new AtomicInteger(); - ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(Content.Chunk.from(ByteBuffer.allocate(1), false)), Content.Chunk.from(new Throwable("should not reach this")))); + AtomicInteger contentSucceededCount = new AtomicInteger(); + ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }), new HttpInput.ErrorContent(new Throwable("should not reach this")))); try (AutoLock ignored = contentProducer.lock()) { - contentProducer.setInterceptor(content -> Content.Chunk.EOF); + contentProducer.setInterceptor(content -> new HttpInput.EofContent()); assertThat(contentProducer.isReady(), is(true)); assertThat(contentProducer.isError(), is(false)); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(content1.isLast(), is(true)); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.isEof(), is(true)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(content2.isLast(), is(true)); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.isEof(), is(true)); } - assertThat(contentReleasedCount.get(), is(1)); + assertThat(contentSucceededCount.get(), is(1)); } @Test public void testAsyncContentProducerInterceptorThrows() { - AtomicInteger contentReleasedCount = new AtomicInteger(); - ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(Content.Chunk.from(ByteBuffer.allocate(1), false)), Content.Chunk.EOF)); + AtomicInteger contentFailedCount = new AtomicInteger(); + ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void failed(Throwable x) + { + contentFailedCount.incrementAndGet(); + } + }), new HttpInput.EofContent())); try (AutoLock ignored = contentProducer.lock()) { contentProducer.setInterceptor(content -> @@ -261,53 +280,74 @@ public void testAsyncContentProducerInterceptorThrows() assertThat(contentProducer.isReady(), is(true)); assertThat(contentProducer.isError(), is(true)); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getCause().getMessage(), is("testAsyncContentProducerInterceptorThrows error")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getCause().getMessage(), is("testAsyncContentProducerInterceptorThrows error")); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getCause().getMessage(), is("testAsyncContentProducerInterceptorThrows error")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getCause().getMessage(), is("testAsyncContentProducerInterceptorThrows error")); } - assertThat(contentReleasedCount.get(), is(1)); + assertThat(contentFailedCount.get(), is(1)); } @Test public void testAsyncContentProducerInterceptorDoesNotConsume() { - AtomicInteger contentReleasedCount = new AtomicInteger(); - AtomicInteger interceptorContentReleasedCount = new AtomicInteger(); - ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(Content.Chunk.from(ByteBuffer.allocate(1), false)), Content.Chunk.EOF)); + AtomicInteger contentFailedCount = new AtomicInteger(); + AtomicInteger interceptorContentFailedCount = new AtomicInteger(); + ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void failed(Throwable x) + { + contentFailedCount.incrementAndGet(); + } + }), new HttpInput.EofContent())); try (AutoLock ignored = contentProducer.lock()) { - contentProducer.setInterceptor(content -> Content.Chunk.from(ByteBuffer.allocate(1), false)); + contentProducer.setInterceptor(content -> new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void failed(Throwable x) + { + interceptorContentFailedCount.incrementAndGet(); + } + }); assertThat(contentProducer.isReady(), is(true)); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); } - assertThat(contentReleasedCount.get(), is(1)); - assertThat(interceptorContentReleasedCount.get(), is(1)); + assertThat(contentFailedCount.get(), is(1)); + assertThat(interceptorContentFailedCount.get(), is(1)); } @Test public void testAsyncContentProducerInterceptorDoesNotConsumeEmptyContent() { - AtomicInteger contentReleasedCount = new AtomicInteger(); + AtomicInteger contentSucceededCount = new AtomicInteger(); AtomicInteger specialContentInterceptedCount = new AtomicInteger(); AtomicInteger nullContentInterceptedCount = new AtomicInteger(); - ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(Content.Chunk.from(ByteBuffer.allocate(0), false)), Content.Chunk.EOF)); + ContentProducer contentProducer = new AsyncContentProducer(new ContentListHttpChannel(List.of(new HttpInput.Content(ByteBuffer.allocate(0)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }), new HttpInput.EofContent())); try (AutoLock ignored = contentProducer.lock()) { contentProducer.setInterceptor(content -> { - if (content.isTerminal()) + if (content.isSpecial()) { specialContentInterceptedCount.incrementAndGet(); return content; @@ -316,15 +356,15 @@ public void testAsyncContentProducerInterceptorDoesNotConsumeEmptyContent() return null; }); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(content1.isLast(), is(true)); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.isEof(), is(true)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(content2.isLast(), is(true)); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.isEof(), is(true)); } - assertThat(contentReleasedCount.get(), is(1)); + assertThat(contentSucceededCount.get(), is(1)); assertThat(specialContentInterceptedCount.get(), is(1)); assertThat(nullContentInterceptedCount.get(), is(1)); } @@ -345,7 +385,7 @@ private Throwable readAndAssertContent(int totalContentBytesCount, String origin else isReadyFalseCount++; - Content.Chunk content = contentProducer.nextContent(); + HttpInput.Content content = contentProducer.nextContent(); nextContentCount++; if (content == null) { @@ -355,11 +395,11 @@ private Throwable readAndAssertContent(int totalContentBytesCount, String origin } assertThat(content, notNullValue()); - if (content.isTerminal()) + if (content.isSpecial()) { - if (content.isLast()) + if (content.isEof()) break; - error = getError(content); + error = content.getError(); break; } @@ -367,7 +407,7 @@ private Throwable readAndAssertContent(int totalContentBytesCount, String origin readBytes += b.length; content.getByteBuffer().get(b); consumedString += new String(b, StandardCharsets.ISO_8859_1); - content.getByteBuffer().position(content.getByteBuffer().position() + content.remaining()); + content.skip(content.remaining()); } assertThat(nextContentCount, is(totalContentCount)); @@ -420,25 +460,19 @@ private static ByteBuffer gzipByteBuffer(ByteBuffer uncompressedBuffer) } } - private Throwable getError(Content.Chunk chunk) + private class ContentListHttpChannel extends HttpChannel { - return chunk instanceof Content.Chunk.Error error ? error.getCause() : null; - } - - private static class ContentListHttpChannel extends HttpChannel - { - private final List contents; - private final Content.Chunk finalContent; + private final List contents; + private final HttpInput.Content finalContent; private int index; - public ContentListHttpChannel(List contents, Content.Chunk finalContent) + public ContentListHttpChannel(List contents, HttpInput.Content finalContent) { - super(null, null); + super(_contextHandler, new MockConnectionMetaData(_connector)); this.contents = contents; this.finalContent = finalContent; } - /* @Override public boolean needContent() { @@ -446,9 +480,9 @@ public boolean needContent() } @Override - public Content produceContent() + public HttpInput.Content produceContent() { - Content c; + HttpInput.Content c; if (index < contents.size()) c = contents.get(index++); else @@ -456,7 +490,11 @@ public Content produceContent() return c; } - */ + @Override + public boolean failAllContent(Throwable failure) + { + return false; + } @Override public boolean failed(Throwable failure) @@ -471,23 +509,23 @@ protected boolean eof() } } - private static class ArrayDelayedHttpChannel extends HttpChannel + private class ArrayDelayedHttpChannel extends HttpChannel { private final ByteBuffer[] byteBuffers; - private final Content.Chunk finalContent; - private final ScheduledExecutorService scheduledExecutorService; + private final HttpInput.Content finalContent; + private final Scheduler scheduler; private final CyclicBarrier barrier; private int counter; - private volatile Content.Chunk nextContent; + private volatile HttpInput.Content nextContent; - public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, Content.Chunk finalContent, ScheduledExecutorService scheduledExecutorService, CyclicBarrier barrier) + public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, HttpInput.Content finalContent, Scheduler scheduler, CyclicBarrier barrier) { - super(new ContextHandler(), new MockConnectionMetaData(new MockConnector(new Server()))); + super(_contextHandler, new MockConnectionMetaData(_connector)); getContextHandler().setServer(getConnectionMetaData().getConnector().getServer()); this.byteBuffers = new ByteBuffer[byteBuffers.length]; this.finalContent = finalContent; - this.scheduledExecutorService = scheduledExecutorService; + this.scheduler = scheduler; this.barrier = barrier; for (int i = 0; i < byteBuffers.length; i++) { @@ -495,16 +533,15 @@ public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, Content.Chunk finalCont } } - /* @Override public boolean needContent() { if (nextContent != null) return true; - scheduledExecutorService.schedule(() -> + scheduler.schedule(() -> { if (byteBuffers.length > counter) - nextContent = new Content.Buffer(byteBuffers[counter++]); + nextContent = new HttpInput.Content(byteBuffers[counter++]); else nextContent = finalContent; try @@ -520,9 +557,9 @@ public boolean needContent() } @Override - public Content produceContent() + public HttpInput.Content produceContent() { - Content result = nextContent; + HttpInput.Content result = nextContent; nextContent = null; return result; } @@ -534,7 +571,6 @@ public boolean failAllContent(Throwable failure) counter = byteBuffers.length; return false; } - */ @Override public boolean failed(Throwable x) @@ -560,7 +596,7 @@ public void destroy() } @Override - public Content.Chunk readFrom(Content.Chunk content) + public HttpInput.Content readFrom(HttpInput.Content content) { return null; } @@ -568,12 +604,12 @@ public Content.Chunk readFrom(Content.Chunk content) private static class AccountingInterceptor implements HttpInput.Interceptor { - private final List contents = new ArrayList<>(); + private final List contents = new ArrayList<>(); @Override - public Content.Chunk readFrom(Content.Chunk content) + public HttpInput.Content readFrom(HttpInput.Content content) { - if (content.isTerminal() || !contents.contains(content)) + if (content.isSpecial() || !contents.contains(content)) contents.add(content); return content; } diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/BlockingContentProducerTest.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/BlockingContentProducerTest.java index f98706061c2f..6872ff144a8c 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/BlockingContentProducerTest.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/BlockingContentProducerTest.java @@ -13,25 +13,20 @@ package org.eclipse.jetty.ee9.nested; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.zip.GZIPOutputStream; -import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.util.component.Destroyable; -import org.eclipse.jetty.util.compression.InflaterPool; import org.eclipse.jetty.util.thread.AutoLock; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -39,17 +34,14 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -@Disabled public class BlockingContentProducerTest { private ScheduledExecutorService scheduledExecutorService; - private InflaterPool inflaterPool; @BeforeEach public void setUp() { scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); - inflaterPool = new InflaterPool(-1, true); } @AfterEach @@ -85,7 +77,7 @@ public void testBlockingContentProducerNoInterceptor() final String originalContentString = asString(buffers); ContentListener contentListener = new ContentListener(); - ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, Content.Chunk.EOF, scheduledExecutorService, contentListener); + ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, new HttpInput.EofContent(), scheduledExecutorService, contentListener); ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(httpChannel)); contentListener.setContentProducer(contentProducer); @@ -108,7 +100,7 @@ public void testBlockingContentProducerNoInterceptorWithError() final Throwable expectedError = new EofException("Early EOF"); ContentListener contentListener = new ContentListener(); - ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, Content.Chunk.from(expectedError), scheduledExecutorService, contentListener); + ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, new HttpInput.ErrorContent(expectedError), scheduledExecutorService, contentListener); ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(httpChannel)); contentListener.setContentProducer(contentProducer); @@ -130,7 +122,7 @@ public void testBlockingContentProducerEofContentIsPassedToInterceptor() final String originalContentString = asString(buffers); ContentListener contentListener = new ContentListener(); - ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, Content.Chunk.EOF, scheduledExecutorService, contentListener); + ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, new HttpInput.EofContent(), scheduledExecutorService, contentListener); ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(httpChannel)); contentListener.setContentProducer(contentProducer); AccountingInterceptor interceptor = new AccountingInterceptor(); @@ -141,17 +133,17 @@ public void testBlockingContentProducerEofContentIsPassedToInterceptor() Throwable error = readAndAssertContent(totalContentBytesCount, originalContentString, buffers.length + 1, contentProducer); assertThat(error, nullValue()); - Content.Chunk lastContent = contentProducer.nextContent(); - assertThat(lastContent.isTerminal(), is(true)); - assertThat(lastContent.isLast(), is(true)); + HttpInput.Content lastContent = contentProducer.nextContent(); + assertThat(lastContent.isSpecial(), is(true)); + assertThat(lastContent.isEof(), is(true)); } assertThat(interceptor.contents.size(), is(4)); - assertThat(interceptor.contents.get(0).isTerminal(), is(false)); - assertThat(interceptor.contents.get(1).isTerminal(), is(false)); - assertThat(interceptor.contents.get(2).isTerminal(), is(false)); - assertThat(interceptor.contents.get(3).isTerminal(), is(true)); - assertThat(interceptor.contents.get(3).isLast(), is(true)); + assertThat(interceptor.contents.get(0).isSpecial(), is(false)); + assertThat(interceptor.contents.get(1).isSpecial(), is(false)); + assertThat(interceptor.contents.get(2).isSpecial(), is(false)); + assertThat(interceptor.contents.get(3).isSpecial(), is(true)); + assertThat(interceptor.contents.get(3).isEof(), is(true)); } @Test @@ -165,7 +157,7 @@ public void testBlockingContentProducerErrorContentIsPassedToInterceptor() final String originalContentString = asString(buffers); ContentListener contentListener = new ContentListener(); - ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, Content.Chunk.from(new Throwable("testBlockingContentProducerErrorContentIsPassedToInterceptor error")), scheduledExecutorService, contentListener); + ArrayDelayedHttpChannel httpChannel = new ArrayDelayedHttpChannel(buffers, new HttpInput.ErrorContent(new Throwable("testBlockingContentProducerErrorContentIsPassedToInterceptor error")), scheduledExecutorService, contentListener); ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(httpChannel)); contentListener.setContentProducer(contentProducer); AccountingInterceptor interceptor = new AccountingInterceptor(); @@ -176,37 +168,44 @@ public void testBlockingContentProducerErrorContentIsPassedToInterceptor() Throwable error = readAndAssertContent(totalContentBytesCount, originalContentString, buffers.length + 1, contentProducer); assertThat(error.getMessage(), is("testBlockingContentProducerErrorContentIsPassedToInterceptor error")); - Content.Chunk lastContent = contentProducer.nextContent(); - assertThat(lastContent.isTerminal(), is(true)); - assertThat(getError(lastContent).getMessage(), is("testBlockingContentProducerErrorContentIsPassedToInterceptor error")); + HttpInput.Content lastContent = contentProducer.nextContent(); + assertThat(lastContent.isSpecial(), is(true)); + assertThat(lastContent.getError().getMessage(), is("testBlockingContentProducerErrorContentIsPassedToInterceptor error")); } assertThat(interceptor.contents.size(), is(4)); - assertThat(interceptor.contents.get(0).isTerminal(), is(false)); - assertThat(interceptor.contents.get(1).isTerminal(), is(false)); - assertThat(interceptor.contents.get(2).isTerminal(), is(false)); - assertThat(interceptor.contents.get(3).isTerminal(), is(true)); - assertThat(getError(interceptor.contents.get(3)).getMessage(), is("testBlockingContentProducerErrorContentIsPassedToInterceptor error")); + assertThat(interceptor.contents.get(0).isSpecial(), is(false)); + assertThat(interceptor.contents.get(1).isSpecial(), is(false)); + assertThat(interceptor.contents.get(2).isSpecial(), is(false)); + assertThat(interceptor.contents.get(3).isSpecial(), is(true)); + assertThat(interceptor.contents.get(3).getError().getMessage(), is("testBlockingContentProducerErrorContentIsPassedToInterceptor error")); } @Test public void testBlockingContentProducerInterceptorGeneratesError() { AtomicInteger contentSucceededCount = new AtomicInteger(); - ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(Content.Chunk.from(ByteBuffer.allocate(1), false)))); + ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }))); try (AutoLock ignored = contentProducer.lock()) { - contentProducer.setInterceptor(content -> Content.Chunk.from(new Throwable("testBlockingContentProducerInterceptorGeneratesError interceptor error"))); + contentProducer.setInterceptor(content -> new HttpInput.ErrorContent(new Throwable("testBlockingContentProducerInterceptorGeneratesError interceptor error"))); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getMessage(), is("testBlockingContentProducerInterceptorGeneratesError interceptor error")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getMessage(), is("testBlockingContentProducerInterceptorGeneratesError interceptor error")); assertThat(contentProducer.isError(), is(true)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getMessage(), is("testBlockingContentProducerInterceptorGeneratesError interceptor error")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getMessage(), is("testBlockingContentProducerInterceptorGeneratesError interceptor error")); } assertThat(contentSucceededCount.get(), is(1)); } @@ -215,20 +214,27 @@ public void testBlockingContentProducerInterceptorGeneratesError() public void testBlockingContentProducerInterceptorGeneratesEof() { AtomicInteger contentSucceededCount = new AtomicInteger(); - ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(Content.Chunk.from(ByteBuffer.allocate(1), false)))); + ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }))); try (AutoLock ignored = contentProducer.lock()) { - contentProducer.setInterceptor(content -> Content.Chunk.EOF); + contentProducer.setInterceptor(content -> new HttpInput.EofContent()); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(content1.isLast(), is(true)); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.isEof(), is(true)); assertThat(contentProducer.isError(), is(false)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(content2.isLast(), is(true)); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.isEof(), is(true)); } assertThat(contentSucceededCount.get(), is(1)); } @@ -237,7 +243,14 @@ public void testBlockingContentProducerInterceptorGeneratesEof() public void testBlockingContentProducerInterceptorThrows() { AtomicInteger contentFailedCount = new AtomicInteger(); - ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(Content.Chunk.from(ByteBuffer.allocate(1), false)))); + ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void failed(Throwable x) + { + contentFailedCount.incrementAndGet(); + } + }))); try (AutoLock ignored = contentProducer.lock()) { contentProducer.setInterceptor(content -> @@ -245,15 +258,15 @@ public void testBlockingContentProducerInterceptorThrows() throw new RuntimeException("testBlockingContentProducerInterceptorThrows error"); }); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getCause().getMessage(), is("testBlockingContentProducerInterceptorThrows error")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getCause().getMessage(), is("testBlockingContentProducerInterceptorThrows error")); assertThat(contentProducer.isError(), is(true)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getCause().getMessage(), is("testBlockingContentProducerInterceptorThrows error")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getCause().getMessage(), is("testBlockingContentProducerInterceptorThrows error")); } assertThat(contentFailedCount.get(), is(1)); } @@ -262,18 +275,25 @@ public void testBlockingContentProducerInterceptorThrows() public void testBlockingContentProducerInterceptorDoesNotConsume() { AtomicInteger contentFailedCount = new AtomicInteger(); - ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(Content.Chunk.from(ByteBuffer.allocate(1), false)))); + ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(new HttpInput.Content(ByteBuffer.allocate(1)) + { + @Override + public void failed(Throwable x) + { + contentFailedCount.incrementAndGet(); + } + }))); try (AutoLock ignored = contentProducer.lock()) { contentProducer.setInterceptor(content -> null); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(getError(content1).getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.getError().getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(getError(content2).getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.getError().getMessage(), endsWith("did not consume any of the 1 remaining byte(s) of content")); } assertThat(contentFailedCount.get(), is(1)); } @@ -284,12 +304,19 @@ public void testBlockingContentProducerInterceptorDoesNotConsumeEmptyContent() AtomicInteger contentSucceededCount = new AtomicInteger(); AtomicInteger specialContentInterceptedCount = new AtomicInteger(); AtomicInteger nullContentInterceptedCount = new AtomicInteger(); - ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(Content.Chunk.from(ByteBuffer.allocate(0), false)))); + ContentProducer contentProducer = new BlockingContentProducer(new AsyncContentProducer(new StaticContentHttpChannel(new HttpInput.Content(ByteBuffer.allocate(0)) + { + @Override + public void succeeded() + { + contentSucceededCount.incrementAndGet(); + } + }))); try (AutoLock ignored = contentProducer.lock()) { contentProducer.setInterceptor(content -> { - if (content.isTerminal()) + if (content.isSpecial()) { specialContentInterceptedCount.incrementAndGet(); return content; @@ -298,13 +325,13 @@ public void testBlockingContentProducerInterceptorDoesNotConsumeEmptyContent() return null; }); - Content.Chunk content1 = contentProducer.nextContent(); - assertThat(content1.isTerminal(), is(true)); - assertThat(content1.isLast(), is(true)); + HttpInput.Content content1 = contentProducer.nextContent(); + assertThat(content1.isSpecial(), is(true)); + assertThat(content1.isEof(), is(true)); - Content.Chunk content2 = contentProducer.nextContent(); - assertThat(content2.isTerminal(), is(true)); - assertThat(content2.isLast(), is(true)); + HttpInput.Content content2 = contentProducer.nextContent(); + assertThat(content2.isSpecial(), is(true)); + assertThat(content2.isEof(), is(true)); } assertThat(contentSucceededCount.get(), is(1)); assertThat(specialContentInterceptedCount.get(), is(1)); @@ -319,14 +346,14 @@ private Throwable readAndAssertContent(int totalContentBytesCount, String origin Throwable error = null; while (true) { - Content.Chunk content = contentProducer.nextContent(); + HttpInput.Content content = contentProducer.nextContent(); nextContentCount++; - if (content.isTerminal()) + if (content.isSpecial()) { - if (content.isLast()) + if (content.isEof()) break; - error = getError(content); + error = content.getError(); break; } @@ -364,31 +391,6 @@ private static String asString(ByteBuffer[] buffers) return sb.toString(); } - private static ByteBuffer gzipByteBuffer(ByteBuffer uncompressedBuffer) - { - try - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GZIPOutputStream output = new GZIPOutputStream(baos); - - byte[] b = new byte[uncompressedBuffer.remaining()]; - uncompressedBuffer.get(b); - output.write(b); - - output.close(); - return ByteBuffer.wrap(baos.toByteArray()); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - } - - private Throwable getError(Content.Chunk chunk) - { - return chunk instanceof Content.Chunk.Error error ? error.getCause() : null; - } - private static class ContentListener { private ContentProducer contentProducer; @@ -413,15 +415,14 @@ private void setContentProducer(ContentProducer contentProducer) private static class StaticContentHttpChannel extends HttpChannel { - private Content.Chunk content; + private HttpInput.Content content; - public StaticContentHttpChannel(Content.Chunk content) + public StaticContentHttpChannel(HttpInput.Content content) { - super(null, null); + super(new ContextHandler(), new MockConnectionMetaData(new MockConnector())); this.content = content; } - /* @Override public boolean needContent() { @@ -429,10 +430,10 @@ public boolean needContent() } @Override - public Content produceContent() + public HttpInput.Content produceContent() { - Content c = content; - content = Content.EOF; + HttpInput.Content c = content; + content = new HttpInput.EofContent(); return c; } @@ -442,8 +443,6 @@ public boolean failAllContent(Throwable failure) return false; } - */ - @Override public boolean failed(Throwable failure) { @@ -460,15 +459,15 @@ protected boolean eof() private static class ArrayDelayedHttpChannel extends HttpChannel { private final ByteBuffer[] byteBuffers; - private final Content.Chunk finalContent; + private final HttpInput.Content finalContent; private final ScheduledExecutorService scheduledExecutorService; private final ContentListener contentListener; private int counter; - private volatile Content.Chunk nextContent; + private volatile HttpInput.Content nextContent; - public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, Content.Chunk finalContent, ScheduledExecutorService scheduledExecutorService, ContentListener contentListener) + public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, HttpInput.Content finalContent, ScheduledExecutorService scheduledExecutorService, ContentListener contentListener) { - super(null, null); + super(new ContextHandler(), new MockConnectionMetaData(new MockConnector())); this.byteBuffers = new ByteBuffer[byteBuffers.length]; this.finalContent = finalContent; this.scheduledExecutorService = scheduledExecutorService; @@ -479,7 +478,6 @@ public ArrayDelayedHttpChannel(ByteBuffer[] byteBuffers, Content.Chunk finalCont } } - /* @Override public boolean needContent() { @@ -488,7 +486,7 @@ public boolean needContent() scheduledExecutorService.schedule(() -> { if (byteBuffers.length > counter) - nextContent = new Content.Buffer(byteBuffers[counter++]); + nextContent = new HttpInput.Content(byteBuffers[counter++]); else nextContent = finalContent; contentListener.onContent(); @@ -497,14 +495,13 @@ public boolean needContent() } @Override - public Content produceContent() + public HttpInput.Content produceContent() { - Content result = nextContent; + HttpInput.Content result = nextContent; nextContent = null; return result; } - @Override public boolean failAllContent(Throwable failure) { @@ -512,7 +509,6 @@ public boolean failAllContent(Throwable failure) counter = byteBuffers.length; return false; } - */ @Override public boolean failed(Throwable x) @@ -538,7 +534,7 @@ public void destroy() } @Override - public Content.Chunk readFrom(Content.Chunk content) + public HttpInput.Content readFrom(HttpInput.Content content) { return null; } @@ -546,10 +542,10 @@ public Content.Chunk readFrom(Content.Chunk content) private static class AccountingInterceptor implements HttpInput.Interceptor { - private List contents = new ArrayList<>(); + private final List contents = new ArrayList<>(); @Override - public Content.Chunk readFrom(Content.Chunk content) + public HttpInput.Content readFrom(HttpInput.Content content) { if (!contents.contains(content)) contents.add(content); diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpServerTestFixture.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpServerTestFixture.java index e17f3227c301..64671957506b 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpServerTestFixture.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/HttpServerTestFixture.java @@ -172,9 +172,8 @@ public boolean process(org.eclipse.jetty.server.Request request, org.eclipse.jet int r = c.remaining(); c.get(content, offset, r); offset += r; - c.release(); } - + c.release(); if (c.isLast()) break; } diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/RequestTest.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/RequestTest.java index 84d56ccf0ebe..fa239aed7228 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/RequestTest.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/RequestTest.java @@ -324,12 +324,11 @@ public void testParamExtractionTimeout() throws Exception _handler._checker = (request, response) -> { request.getParameterMap(); - // should have thrown a BadMessageException + // return false; }; - //Send a request with query string with illegal hex code to cause - //an exception parsing the params + //Send a request with a form body that is smaller than Content-Length. String request = "POST / HTTP/1.1\r\n" + "Host: whatever\r\n" + "Content-Type: " + MimeTypes.Type.FORM_ENCODED.asString() + "\n" + @@ -1820,7 +1819,7 @@ public void testHashDOSSize() throws Exception @Test public void testNotSupportedCharacterEncoding() { - Request request = new Request(new HttpChannel(_context, new MockConnectionMetaData(new MockConnector())), null); + Request request = new Request(new HttpChannel(_context, new MockConnectionMetaData(_connector)), null); assertThrows(UnsupportedEncodingException.class, () -> request.setCharacterEncoding("doesNotExist")); } @@ -1828,7 +1827,7 @@ public void testNotSupportedCharacterEncoding() public void testGetterSafeFromNullPointerException() { // This is only needed for tests that mock with null values. - Request request = new Request(new HttpChannel(_context, new MockConnectionMetaData(new MockConnector())), null); + Request request = new Request(new HttpChannel(_context, new MockConnectionMetaData(_connector)), null); assertNull(request.getAuthType()); assertNull(request.getAuthentication()); @@ -1869,7 +1868,7 @@ public void testEncoding() throws Exception public void testPushBuilder() { String uri = "http://host/foo/something"; - HttpChannel httpChannel = new HttpChannel(_context, new MockConnectionMetaData(new MockConnector())); + HttpChannel httpChannel = new HttpChannel(_context, new MockConnectionMetaData(_connector)); Request request = new MockRequest(httpChannel, new HttpInput(httpChannel)); request.getResponse().getHttpFields().add(new HttpCookie.SetCookieHttpField(new HttpCookie("good", "thumbsup", 100), CookieCompliance.RFC6265)); request.getResponse().getHttpFields().add(new HttpCookie.SetCookieHttpField(new HttpCookie("bonza", "bewdy", 1), CookieCompliance.RFC6265)); @@ -1909,7 +1908,7 @@ public void testPushBuilder() public void testPushBuilderWithIdNoAuth() { String uri = "http://host/foo/something"; - HttpChannel httpChannel = new HttpChannel(_context, new MockConnectionMetaData(new MockConnector())); + HttpChannel httpChannel = new HttpChannel(_context, new MockConnectionMetaData(_connector)); Request request = new MockRequest(httpChannel, new HttpInput(httpChannel)) { @Override diff --git a/jetty-ee9/jetty-ee9-openid/src/main/config/etc/jetty-ee9-openid.xml b/jetty-ee9/jetty-ee9-openid/src/main/config/etc/jetty-ee9-openid.xml index a5e07e01b7f6..fda52ab002ed 100644 --- a/jetty-ee9/jetty-ee9-openid/src/main/config/etc/jetty-ee9-openid.xml +++ b/jetty-ee9/jetty-ee9-openid/src/main/config/etc/jetty-ee9-openid.xml @@ -4,7 +4,7 @@ - + diff --git a/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdConfiguration.java b/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdConfiguration.java index f35a1805243f..a4def8a7134d 100644 --- a/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdConfiguration.java +++ b/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdConfiguration.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.util.ajax.JSON; import org.eclipse.jetty.util.annotation.Name; diff --git a/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdCredentials.java b/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdCredentials.java index 351e53658f47..805255884a99 100644 --- a/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdCredentials.java +++ b/jetty-ee9/jetty-ee9-openid/src/main/java/org/eclipse/jetty/ee9/security/openid/OpenIdCredentials.java @@ -20,11 +20,11 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.Authentication; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.FormRequestContent; +import org.eclipse.jetty.client.Authentication; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.ajax.JSON; import org.slf4j.Logger; diff --git a/jetty-ee9/jetty-ee9-openid/src/test/java/org/eclipse/jetty/ee9/security/openid/OpenIdAuthenticationTest.java b/jetty-ee9/jetty-ee9-openid/src/test/java/org/eclipse/jetty/ee9/security/openid/OpenIdAuthenticationTest.java index fc4a0abcf5a5..1ee007e4e17a 100644 --- a/jetty-ee9/jetty-ee9-openid/src/test/java/org/eclipse/jetty/ee9/security/openid/OpenIdAuthenticationTest.java +++ b/jetty-ee9/jetty-ee9-openid/src/test/java/org/eclipse/jetty/ee9/security/openid/OpenIdAuthenticationTest.java @@ -22,8 +22,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.security.ConstraintMapping; import org.eclipse.jetty.ee9.security.ConstraintSecurityHandler; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; @@ -251,4 +251,4 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t response.getWriter().println("
Home"); } } -} \ No newline at end of file +} diff --git a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml index 0d3002642d98..6e24cfbe6c32 100644 --- a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -20,7 +20,6 @@ org.eclipse.jetty.ee9.osgi jetty-ee9-osgi-boot - ${project.version} provided @@ -57,8 +56,8 @@ parse-version - ${jsp.impl.version} - jspImpl + ${jsp.impl.version} + jspImpl diff --git a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/pom.xml b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/pom.xml index 13c1b2794193..a6ad4b9c7202 100644 --- a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -16,22 +16,18 @@ org.eclipse.jetty.ee9 jetty-ee9-annotations - ${project.version} org.eclipse.jetty.ee9 jetty-ee9-webapp - ${project.version} org.eclipse.jetty jetty-osgi - ${project.version} org.eclipse.jetty jetty-jmx - ${project.version} org.eclipse.platform diff --git a/jetty-ee9/jetty-ee9-osgi/pom.xml b/jetty-ee9/jetty-ee9-osgi/pom.xml index ad3ce1f5d631..5c4bccc7b1cb 100644 --- a/jetty-ee9/jetty-ee9-osgi/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/pom.xml @@ -7,25 +7,11 @@ 4.0.0 org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi EE9 :: Jetty :: OSGi pom - 8.1.0 - 3.18.200 - 3.11.100 - 1.6.1 - 1.5.0 - 1.4.1 - 3.7.100 - 1.2.0 - 1.2.0 - 1.0.2 - 1.0.1 - 1.5.4 - 1.0.2 - 1.0.0-v20070606 true @@ -38,6 +24,21 @@ test-jetty-ee9-osgi + + + + org.eclipse.jetty.ee9.osgi + jetty-ee9-osgi-boot + ${project.version} + + + org.eclipse.jetty.ee9.osgi + jetty-ee9-osgi-boot-jsp + ${project.version} + + + + @@ -65,77 +66,5 @@ - - - org.apache.maven.plugins - maven-eclipse-plugin - - prevent/overwriting/by/pointing/to/nonexisting/MANIFEST.MF - true - true - - **/.svn/** - - - - - - - - - org.eclipse.platform - org.eclipse.osgi.services - ${osgi-services-version} - - - - jakarta.servlet - servlet-api - - - - org.apache.felix - org.osgi.foundation - - - - - org.eclipse.platform - org.eclipse.osgi - ${osgi-version} - - - org.osgi - org.osgi.service.cm - ${osgi-service-cm-version} - - - org.osgi - org.osgi.service.component - ${osgi-service-component-version} - - - org.osgi - org.osgi.service.event - ${osgi-service-event-version} - - - org.osgi - org.osgi.util.tracker - ${osgi-util-tracker-version} - - - org.eclipse.equinox.http - servlet - ${equinox-http-servlet-version} - - - org.osgi - osgi.annotation - ${osgi-annotation-version} - - - - diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-fragment/pom.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-fragment/pom.xml index ebae44ce91e5..a8d7e115270b 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-fragment/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-fragment/pom.xml @@ -1,9 +1,8 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-ee9-osgi-fragment diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-server/pom.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-server/pom.xml index d977c10c33ea..c5295cab37e8 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-server/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-server/pom.xml @@ -1,7 +1,7 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT 4.0.0 diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-webapp-resources/pom.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-webapp-resources/pom.xml index fe748b9e3071..4aa11535f8c1 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-webapp-resources/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi-webapp-resources/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT 4.0.0 @@ -30,7 +30,7 @@ ${basedir}/target/classes - src/main/resources + src/main/resources
diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/pom.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/pom.xml index 3848dcc1817a..43e39111d63a 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/pom.xml @@ -1,9 +1,8 @@ org.eclipse.jetty.ee9.osgi - jetty-ee9-osgi-project + jetty-ee9-osgi 12.0.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-ee9-osgi @@ -13,12 +12,6 @@ ${project.groupId}.boot.test.osgi https://download.eclipse.org/jetty/orbit/ target/distribution - 4.13.1 - 2.6.2 - 1.8.3 - 3.0.0 - 1.3.6 - 1.2 true @@ -26,20 +19,17 @@ org.ops4j.pax.exam pax-exam - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-inject - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-container-forked - ${pax.exam.version} test @@ -55,12 +45,10 @@ org.ops4j.pax.tinybundles tinybundles - ${tinybundles.version} org.ops4j.pax.swissbox pax-swissbox-framework - ${swissbox.version} test @@ -72,31 +60,26 @@ org.ops4j.pax.swissbox pax-swissbox-tracker - ${swissbox.version} test org.ops4j.pax.exam pax-exam-junit4 - ${pax.exam.version} test org.ops4j.pax.exam pax-exam-link-mvn - ${pax.exam.version} test org.ops4j.pax.url pax-url-aether - ${pax.url.version} test org.ops4j.pax.url pax-url-wrap - ${pax.url.version} test @@ -128,37 +111,31 @@ org.eclipse.platform org.eclipse.osgi.util - ${osgi-util-version} test org.apache.geronimo.specs geronimo-atinject_1.0_spec - 1.2 test org.osgi org.osgi.util.promise - ${osgi-util-promise-version} test org.osgi org.osgi.util.measurement - ${osgi-util-measurement-version} test org.osgi org.osgi.util.position - ${osgi-util-position-version} test org.osgi org.osgi.util.xml - ${osgi-util-xml-version} test @@ -182,7 +159,6 @@ org.eclipse.jetty.ee9.osgi jetty-ee9-osgi-boot - ${project.version} test @@ -198,7 +174,6 @@ org.eclipse.jetty.ee9.osgi jetty-ee9-osgi-boot-jsp - ${project.version} test @@ -243,7 +218,6 @@ org.apache.aries.spifly org.apache.aries.spifly.dynamic.bundle - ${spifly.version} test @@ -461,72 +435,60 @@ org.ow2.asm asm test - ${asm.version} org.ow2.asm asm-commons test - ${asm.version} org.ow2.asm asm-tree test - ${asm.version} org.ow2.asm asm-analysis test - ${asm.version} org.ow2.asm asm-util test - ${asm.version} org.eclipse.jetty.http2 jetty-http2-client - ${project.version} test org.eclipse.jetty.http2 jetty-http2-client-transport - ${project.version} test org.eclipse.jetty jetty-alpn-conscrypt-server - ${project.version} test org.eclipse.jetty jetty-alpn-conscrypt-client - ${project.version} test org.conscrypt conscrypt-openjdk-uber - ${conscrypt.version} test org.eclipse.jetty jetty-alpn-java-server - ${project.version} test org.eclipse.jetty jetty-alpn-java-client - ${project.version} test diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java index 2f0e35275e50..81749afaa642 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2Conscrypt.java @@ -21,8 +21,8 @@ import java.util.concurrent.Executor; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2JDK9.java b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2JDK9.java index b301012eeb7c..3e227ab93416 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2JDK9.java +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootHTTP2JDK9.java @@ -21,8 +21,8 @@ import java.util.concurrent.Executor; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithAnnotations.java b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithAnnotations.java index 0ab63beb129f..8bf3fd0b2a0f 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithAnnotations.java +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithAnnotations.java @@ -17,11 +17,11 @@ import java.util.List; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.MultiPart; diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithJsp.java b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithJsp.java index d29edeaf2bde..1f1261672b4b 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithJsp.java +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiBootWithJsp.java @@ -16,8 +16,8 @@ import java.util.ArrayList; import javax.inject.Inject; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiClasspathResources.java b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiClasspathResources.java index 983278e4e27d..4e4cf9e9c9d9 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiClasspathResources.java +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/java/org/eclipse/jetty/ee9/osgi/test/TestJettyOSGiClasspathResources.java @@ -20,8 +20,8 @@ import javax.inject.Inject; import aQute.bnd.osgi.Constants; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AbstractProxyServlet.java b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AbstractProxyServlet.java index 079fc65ced6f..5d2975ff649e 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AbstractProxyServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AbstractProxyServlet.java @@ -37,9 +37,9 @@ import org.eclipse.jetty.client.ContinueProtocolHandler; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.ProtocolHandlers; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServlet.java b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServlet.java index 2933dafd5ec0..0dd92330322c 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServlet.java @@ -35,13 +35,13 @@ import jakarta.servlet.WriteListener; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.client.ContentDecoder; import org.eclipse.jetty.client.GZIPContentDecoder; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.Content; @@ -439,6 +439,7 @@ public void onHeaders(Response serverResponse) @Override public void onContent(Response serverResponse, Content.Chunk chunk, Runnable demander) { + chunk.retain(); Callback callback = Callback.from(chunk::release, Callback.from(demander, serverResponse::abort)); try { diff --git a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncProxyServlet.java b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncProxyServlet.java index 3b2e959aa603..8aacc8ac28c1 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncProxyServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/AsyncProxyServlet.java @@ -25,9 +25,9 @@ import jakarta.servlet.WriteListener; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.server.handler.ConnectHandler; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingCallback; diff --git a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/BalancerServlet.java b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/BalancerServlet.java index 153ca0158f7c..49e0c5e98a27 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/BalancerServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/BalancerServlet.java @@ -26,7 +26,7 @@ import jakarta.servlet.UnavailableException; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.URIUtil; public class BalancerServlet extends ProxyServlet diff --git a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/ProxyServlet.java b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/ProxyServlet.java index 13ba0b3a5926..29f48d4f0893 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/ProxyServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/main/java/org/eclipse/jetty/ee9/proxy/ProxyServlet.java @@ -24,11 +24,11 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.InputStreamRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.server.handler.ConnectHandler; import org.eclipse.jetty.util.Callback; @@ -216,7 +216,7 @@ public void onContent(Response proxyResponse, Content.Chunk chunk, Runnable dema content.get(buffer); offset = 0; } - + chunk.retain(); Callback callback = Callback.from(chunk::release, Callback.from(demander, proxyResponse::abort)); onResponseContent(request, response, proxyResponse, buffer, offset, length, callback); } diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java index e888e8377a54..66012cff4c17 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/AsyncMiddleManServletTest.java @@ -47,14 +47,14 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/BalancerServletTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/BalancerServletTest.java index 7550d0c1606a..ed53c2386883 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/BalancerServletTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/BalancerServletTest.java @@ -24,8 +24,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.rewrite.handler.RewriteHandler; diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/CachingProxyServlet.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/CachingProxyServlet.java index f2450b298d3d..918d87416287 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/CachingProxyServlet.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/CachingProxyServlet.java @@ -21,9 +21,8 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpContentResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.Callback; /** @@ -72,7 +71,7 @@ protected void onResponseContent(HttpServletRequest request, HttpServletResponse protected void onProxyResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) { byte[] content = temp.remove(request.getRequestURI()).toByteArray(); - ContentResponse cached = new HttpContentResponse(proxyResponse, content, null, null); + ContentResponse cached = ContentResponse.from(proxyResponse, content, null, null); cache.put(request.getRequestURI(), cached); super.onProxyResponseSuccess(request, response, proxyResponse); } diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ClientAuthProxyTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ClientAuthProxyTest.java index 130921c4280f..008d0fcdd7bc 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ClientAuthProxyTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ClientAuthProxyTest.java @@ -31,12 +31,12 @@ import javax.security.auth.x500.X500Principal; import jakarta.servlet.http.HttpServletRequest; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpScheme; @@ -560,7 +560,7 @@ private static class ProxyAliasClientSslContextFactory extends SslContextFactory @Override public SSLEngine newSslEngine(String host, int port, Map context) { - HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); + Destination destination = (Destination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY); String user = (String)destination.getOrigin().getTag(); return factories.compute(user, (key, value) -> value != null ? value : this).newSSLEngine(host, port); } diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyServerTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyServerTest.java index 46bd2bee644c..8dfaccdf4638 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyServerTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyServerTest.java @@ -18,11 +18,11 @@ import java.util.stream.Stream; import jakarta.servlet.http.HttpServletRequest; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyTLSServerTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyTLSServerTest.java index 777af140586f..570395bc3784 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyTLSServerTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ForwardProxyTLSServerTest.java @@ -31,16 +31,16 @@ import javax.net.ssl.X509ExtendedKeyManager; import jakarta.servlet.ServletException; +import org.eclipse.jetty.client.BasicAuthentication; +import org.eclipse.jetty.client.Connection; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.FutureResponseListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; import org.eclipse.jetty.client.Origin; -import org.eclipse.jetty.client.api.Connection; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.client.util.BasicAuthentication; -import org.eclipse.jetty.client.util.FutureResponseListener; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpScheme; @@ -313,7 +313,7 @@ public void succeeded(Connection result) assertTrue(connectionLatch.await(5, TimeUnit.SECONDS)); String body2 = "body=" + content1; - org.eclipse.jetty.client.api.Request request2 = httpClient.newRequest("localhost", serverConnector.getLocalPort()) + org.eclipse.jetty.client.Request request2 = httpClient.newRequest("localhost", serverConnector.getLocalPort()) .scheme(HttpScheme.HTTPS.asString()) .method(HttpMethod.POST) .path("/echo") @@ -799,10 +799,10 @@ public void testRequestCompletionDelayed(SslContextFactory.Server proxyTLS) thro try { - httpClient.getRequestListeners().add(new org.eclipse.jetty.client.api.Request.Listener() + httpClient.getRequestListeners().add(new org.eclipse.jetty.client.Request.Listener() { @Override - public void onSuccess(org.eclipse.jetty.client.api.Request request) + public void onSuccess(org.eclipse.jetty.client.Request request) { if (HttpMethod.CONNECT.is(request.getMethod())) sleep(250); diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletFailureTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletFailureTest.java index 9a286f1eb273..810d07d8317c 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletFailureTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletFailureTest.java @@ -29,13 +29,13 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletLoadTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletLoadTest.java index 648925a6341f..3676fa522284 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletLoadTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletLoadTest.java @@ -23,10 +23,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpProxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BytesRequestContent; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletTest.java index 10c4738c1aa6..2d4af79a1fa7 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ProxyServletTest.java @@ -27,9 +27,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -61,19 +59,19 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequestWrapper; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; import org.eclipse.jetty.client.ConnectionPool; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpProxy; +import org.eclipse.jetty.client.InputStreamResponseListener; import org.eclipse.jetty.client.ProxyConfiguration.Proxy; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.ee9.servlet.FilterHolder; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; @@ -1294,7 +1292,7 @@ private boolean await(CountDownLatch latch, long ms) throws IOException // Make sure the proxy does not receive chunk2. assertEquals(-1, input.read()); - HttpDestination destination = (HttpDestination)client.resolveDestination(request); + Destination destination = client.resolveDestination(request); ConnectionPool connectionPool = destination.getConnectionPool(); assertTrue(connectionPool.isEmpty()); } @@ -1367,7 +1365,7 @@ private boolean await(CountDownLatch latch, long ms) throws IOException input.read(); }); - HttpDestination destination = (HttpDestination)client.resolveDestination(request); + Destination destination = client.resolveDestination(request); ConnectionPool connectionPool = destination.getConnectionPool(); assertTrue(connectionPool.isEmpty()); } diff --git a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ReverseProxyTest.java b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ReverseProxyTest.java index eaf5ad9cc72b..14f13022971f 100644 --- a/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ReverseProxyTest.java +++ b/jetty-ee9/jetty-ee9-proxy/src/test/java/org/eclipse/jetty/ee9/proxy/ReverseProxyTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.server.HttpConfiguration; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ComponentWrapTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ComponentWrapTest.java index d3a3c7b1b718..f35ca5c0b83d 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ComponentWrapTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ComponentWrapTest.java @@ -34,8 +34,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/FormTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/FormTest.java index 127c43b5be32..774581d933cb 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/FormTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/FormTest.java @@ -22,10 +22,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.FormRequestContent; import org.eclipse.jetty.ee9.nested.ContextHandler; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerBreakEvenSizeTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerBreakEvenSizeTest.java index b9e2362e39c2..c946d6980b36 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerBreakEvenSizeTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerBreakEvenSizeTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerCommitTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerCommitTest.java index 3075d79caae6..ddcc3776a40a 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerCommitTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerCommitTest.java @@ -23,9 +23,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerIsHandledTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerIsHandledTest.java index cae14fd2cbf2..5eebafb4ca52 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerIsHandledTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/GzipHandlerIsHandledTest.java @@ -15,8 +15,8 @@ import java.util.concurrent.LinkedBlockingQueue; +import org.eclipse.jetty.client.ContentResponse; 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.Response; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/InitServletTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/InitServletTest.java index bffb1a167709..c263fd472e9d 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/InitServletTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/InitServletTest.java @@ -23,8 +23,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/MultiPartServletTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/MultiPartServletTest.java index 2e8dd49ee297..863b0232d4e8 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/MultiPartServletTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/MultiPartServletTest.java @@ -29,13 +29,13 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.Part; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.ee9.nested.HttpChannel; import org.eclipse.jetty.ee9.nested.MultiPartFormInputStream; import org.eclipse.jetty.http.HttpFields; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/StaticFromJarServerTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/StaticFromJarServerTest.java index 5312b0597313..6479da252e7c 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/StaticFromJarServerTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/StaticFromJarServerTest.java @@ -18,9 +18,9 @@ import java.nio.file.Files; import java.nio.file.Path; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.ClientConnector; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AbstractTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AbstractTest.java index 5ea49e18d1a7..389cf82a830b 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AbstractTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AbstractTest.java @@ -24,10 +24,10 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClientTransport; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; -import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; +import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.fcgi.server.ServerFCGIConnectionFactory; import org.eclipse.jetty.http2.HTTP2Cipher; import org.eclipse.jetty.http2.client.HTTP2Client; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AsyncIOServletTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AsyncIOServletTest.java index ac58d0f6bf98..21cc32db5696 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AsyncIOServletTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/AsyncIOServletTest.java @@ -42,16 +42,16 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.http.HttpConnectionOverHTTP; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.InputStreamRequestContent; -import org.eclipse.jetty.client.util.OutputStreamRequestContent; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.OutputStreamRequestContent; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP; import org.eclipse.jetty.ee9.nested.ContextHandler; import org.eclipse.jetty.ee9.nested.HttpInput; import org.eclipse.jetty.ee9.nested.HttpOutput; @@ -63,7 +63,6 @@ import org.eclipse.jetty.http2.client.transport.internal.HttpConnectionOverHTTP2; import org.eclipse.jetty.http2.internal.HTTP2Session; import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.internal.HttpChannelState; @@ -1146,9 +1145,9 @@ public void onError(Throwable x) }); Destination destination = client.resolveDestination(request); - FuturePromise promise = new FuturePromise<>(); + FuturePromise promise = new FuturePromise<>(); destination.newConnection(promise); - org.eclipse.jetty.client.api.Connection connection = promise.get(5, TimeUnit.SECONDS); + org.eclipse.jetty.client.Connection connection = promise.get(5, TimeUnit.SECONDS); CountDownLatch clientLatch = new CountDownLatch(1); connection.send(request, result -> { @@ -1211,71 +1210,71 @@ protected void service(HttpServletRequest request, HttpServletResponse response) httpInput.addInterceptor(new HttpInput.Interceptor() { int state = 0; - Content.Chunk saved; + HttpInput.Content saved; @Override - public Content.Chunk readFrom(Content.Chunk chunk) + public HttpInput.Content readFrom(HttpInput.Content content) { switch (state) { case 0: // null transform - chunk.skip(chunk.remaining()); - chunk.release(); + content.skip(content.remaining()); + content.succeeded(); state++; return null; case 1: { // copy transform - if (!chunk.hasRemaining()) + if (!content.hasContent()) { state++; - return chunk; + return content; } - ByteBuffer copy = wrap(toArray(chunk.getByteBuffer())); - chunk.skip(copy.remaining()); - chunk.release(); - return Content.Chunk.from(copy, false); + ByteBuffer copy = wrap(toArray(content.getByteBuffer())); + content.skip(copy.remaining()); + content.succeeded(); + return new HttpInput.Content(copy); } case 2: // byte by byte - if (!chunk.hasRemaining()) + if (!content.hasContent()) { state++; - return chunk; + return content; } byte[] b = new byte[1]; - int l = chunk.get(b, 0, 1); - if (!chunk.hasRemaining()) - chunk.release(); - return Content.Chunk.from(wrap(b, 0, l), false); + int l = content.get(b, 0, 1); + if (!content.hasContent()) + content.succeeded(); + return new HttpInput.Content(wrap(b, 0, l)); case 3: { // double vision - if (!chunk.hasRemaining()) + if (!content.hasContent()) { if (saved == null) { state++; - return chunk; + return content; } - Content.Chunk ref = saved; + HttpInput.Content ref = saved; saved = null; return ref; } - byte[] data = toArray(chunk.getByteBuffer()); - chunk.skip(data.length); - chunk.release(); - saved = Content.Chunk.from(wrap(data), false); - return Content.Chunk.from(wrap(data), false); + byte[] data = toArray(content.getByteBuffer()); + content.skip(data.length); + content.succeeded(); + saved = new HttpInput.Content(wrap(data)); + return new HttpInput.Content(wrap(data)); } default: - return chunk; + return content; } } }); @@ -1560,7 +1559,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) HttpInput httpInput = ((org.eclipse.jetty.ee9.nested.Request)request).getHttpInput(); httpInput.addInterceptor(chunk -> { - if (!chunk.hasRemaining()) + if (!chunk.hasContent()) return chunk; // skip contents with odd numbers @@ -1568,16 +1567,16 @@ protected void service(HttpServletRequest request, HttpServletResponse response) duplicate.get(); byte integer = duplicate.get(); int idx = Character.getNumericValue(integer); - Content.Chunk chunkCopy = Content.Chunk.from(chunk.getByteBuffer().duplicate(), false); + HttpInput.Content chunkCopy = new HttpInput.Content(chunk.getByteBuffer().duplicate()); chunk.skip(chunk.remaining()); - chunk.release(); + chunk.succeeded(); if (idx % 2 == 0) return chunkCopy; return null; }); httpInput.addInterceptor(chunk -> { - if (!chunk.hasRemaining()) + if (!chunk.hasContent()) return chunk; // reverse the bytes @@ -1585,7 +1584,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) byte[] bytes = new byte[2]; bytes[1] = byteBuffer.get(); bytes[0] = byteBuffer.get(); - return Content.Chunk.from(wrap(bytes), false); + return new HttpInput.Content(wrap(bytes)); }); AsyncContext asyncContext = request.startAsync(); diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/BlockedIOTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/BlockedIOTest.java index 597039275a4e..8853e96f3892 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/BlockedIOTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/BlockedIOTest.java @@ -22,7 +22,7 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.util.AsyncRequestContent; +import org.eclipse.jetty.client.AsyncRequestContent; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.junit.jupiter.api.Disabled; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpClientContinueTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpClientContinueTest.java index 33e5894770fe..33f6068925af 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpClientContinueTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpClientContinueTest.java @@ -34,15 +34,15 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.ContinueProtocolHandler; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.FutureResponseListener; +import org.eclipse.jetty.client.FutureResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; @@ -306,7 +306,7 @@ public void onComplete(Result result) @MethodSource("transportsNoFCGI") public void testExpect100ContinueWithContentWithResponseFailureBefore100Continue(Transport transport) throws Exception { - AtomicReference clientRequestRef = new AtomicReference<>(); + AtomicReference clientRequestRef = new AtomicReference<>(); CountDownLatch clientLatch = new CountDownLatch(1); CountDownLatch serverLatch = new CountDownLatch(1); @@ -330,7 +330,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) }); byte[] content = new byte[1024]; - org.eclipse.jetty.client.api.Request clientRequest = client.newRequest(newURI(transport)); + Request clientRequest = client.newRequest(newURI(transport)); clientRequestRef.set(clientRequest); clientRequest .headers(headers -> headers.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) @@ -355,7 +355,7 @@ public void onComplete(Result result) @MethodSource("transportsNoFCGI") public void testExpect100ContinueWithContentWithResponseFailureAfter100Continue(Transport transport) throws Exception { - AtomicReference clientRequestRef = new AtomicReference<>(); + AtomicReference clientRequestRef = new AtomicReference<>(); CountDownLatch clientLatch = new CountDownLatch(1); CountDownLatch serverLatch = new CountDownLatch(1); start(transport, new HttpServlet() @@ -380,7 +380,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) }); byte[] content = new byte[1024]; - org.eclipse.jetty.client.api.Request clientRequest = client.newRequest(newURI(transport)); + Request clientRequest = client.newRequest(newURI(transport)); clientRequestRef.set(clientRequest); clientRequest .headers(headers -> headers.put(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE)) diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpTrailersTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpTrailersTest.java index 707234fef44d..766335025a20 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpTrailersTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/HttpTrailersTest.java @@ -30,11 +30,11 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BytesRequestContent; -import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -176,8 +176,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = r.getTrailers(); assertNotNull(trailers); assertEquals(trailerValue, trailers.get(trailerName)); failure.set(null); @@ -198,8 +197,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - assertNull(httpResponse.getTrailers()); + assertNull(r.getTrailers()); failure.set(null); } catch (Throwable x) @@ -232,8 +230,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) { try { - HttpResponse httpResponse = (HttpResponse)r; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = r.getTrailers(); assertNull(trailers); failure.set(null); } @@ -274,7 +271,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) client.newRequest(newURI(transport)) .timeout(15, TimeUnit.SECONDS) .send(listener); - org.eclipse.jetty.client.api.Response response = listener.get(5, TimeUnit.SECONDS); + Response response = listener.get(5, TimeUnit.SECONDS); assertEquals(HttpStatus.OK_200, response.getStatus()); InputStream input = listener.getInputStream(); @@ -294,8 +291,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) // Wait for the request/response cycle to complete. listener.await(5, TimeUnit.SECONDS); - HttpResponse httpResponse = (HttpResponse)response; - HttpFields trailers = httpResponse.getTrailers(); + HttpFields trailers = response.getTrailers(); assertNotNull(trailers); assertEquals(trailerValue, trailers.get(trailerName)); } @@ -328,7 +324,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) .timeout(5, TimeUnit.SECONDS) .send(result -> { - HttpResponse response = (HttpResponse)result.getResponse(); + Response response = result.getResponse(); assertEquals(HttpStatus.OK_200, response.getStatus()); assertNull(response.getTrailers()); assertNull(response.getHeaders().get("name")); diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/InformationalResponseTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/InformationalResponseTest.java index 515c494bfe3d..04b80535e8a8 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/InformationalResponseTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/InformationalResponseTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/PushCacheFilterTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/PushCacheFilterTest.java index 5cf016e77a2a..03f1bdf53e0a 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/PushCacheFilterTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/PushCacheFilterTest.java @@ -25,10 +25,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpDestination; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Destination; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.ee9.servlets.PushCacheFilter; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; @@ -196,7 +196,7 @@ else if (requestURI.endsWith(secondaryResource)) assertTrue(pushLatch.await(5, TimeUnit.SECONDS)); // Make sure the connection is sane. - HttpDestination destination = (HttpDestination)client.getDestinations().get(0); + Destination destination = client.getDestinations().get(0); assertFalse(destination.getConnectionPool().isEmpty()); } diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/RequestReaderTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/RequestReaderTest.java index e85222335604..ec29706a992f 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/RequestReaderTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/RequestReaderTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.BytesRequestContent; +import org.eclipse.jetty.client.BytesRequestContent; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/ServerTimeoutsTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/ServerTimeoutsTest.java index c64edc41170a..f2b9f283ccc5 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/ServerTimeoutsTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/ServerTimeoutsTest.java @@ -33,10 +33,10 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.AsyncRequestContent; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.AsyncRequestContent; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Response; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http2.FlowControlStrategy; @@ -600,7 +600,6 @@ protected void service(HttpServletRequest request, HttpServletResponse response) .onResponseContentAsync((response, chunk, demander) -> { objects.offer(chunk.remaining()); - chunk.release(); objects.offer(demander); }) .send(result -> diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/VirtualThreadsTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/VirtualThreadsTest.java index a617af8cda95..0d54df971e5a 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/VirtualThreadsTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-client-transports/src/test/java/org/eclipse/jetty/ee9/test/client/transport/VirtualThreadsTest.java @@ -30,8 +30,8 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.StringRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.StringRequestContent; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.VirtualThreads; diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml index 4e9381936751..66aa233e619b 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml @@ -2,7 +2,7 @@ - + diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee9/tests/webapp/websocket/WebSocketClientServlet.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee9/tests/webapp/websocket/WebSocketClientServlet.java index 6ea5d3f6dec2..0c9856c81c57 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee9/tests/webapp/websocket/WebSocketClientServlet.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-websocket-client-webapp/src/main/java/org/eclipse/jetty/ee9/tests/webapp/websocket/WebSocketClientServlet.java @@ -25,7 +25,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketClose; import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketConnect; diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java index a2039aec466f..429eef441b7a 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/HugeResourceTest.java @@ -35,13 +35,13 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; -import org.eclipse.jetty.client.util.InputStreamResponseListener; -import org.eclipse.jetty.client.util.MultiPartRequestContent; -import org.eclipse.jetty.client.util.PathRequestContent; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.PathRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/JsrUpgradeListener.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/JsrUpgradeListener.java index 3515f9e516a3..a8b6890881c5 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/JsrUpgradeListener.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/JsrUpgradeListener.java @@ -21,8 +21,8 @@ import jakarta.websocket.ClientEndpointConfig.Configurator; import jakarta.websocket.HandshakeResponse; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.websocket.core.client.UpgradeListener; @@ -36,7 +36,7 @@ public JsrUpgradeListener(Configurator configurator) } @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { if (configurator == null) return; @@ -62,7 +62,7 @@ public void onHandshakeRequest(HttpRequest request) } @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { if (configurator == null) return; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java index d6cfaba5a5e7..c52ad3c321a6 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/java/examples/SecureClientContainerExample.java @@ -20,7 +20,7 @@ import jakarta.websocket.ClientEndpointConfig; import jakarta.websocket.WebSocketContainer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.ee9.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.jmx.MBeanContainer; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml index f2bab0819842..6e8e0b591b54 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/test/resources/jetty-websocket-httpclient.xml @@ -2,7 +2,7 @@ - + @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientClassLoaderTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientClassLoaderTest.java index d480cd6ef956..e1d24dfea14b 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientClassLoaderTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientClassLoaderTest.java @@ -28,9 +28,9 @@ import jakarta.websocket.Session; import jakarta.websocket.WebSocketContainer; import jakarta.websocket.server.ServerEndpoint; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.webapp.Configuration; import org.eclipse.jetty.ee9.webapp.Configurations; import org.eclipse.jetty.ee9.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java index 817ff5394b5c..ee018851dbeb 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerEmbeddedTest.java @@ -21,8 +21,8 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.websocket.ContainerProvider; import jakarta.websocket.WebSocketContainer; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.ee9.websocket.jakarta.client.JakartaWebSocketShutdownContainer; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java index b374cf1c0075..e1fa02a93d5f 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/JakartaClientShutdownWithServerWebAppTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.websocket.ContainerProvider; import jakarta.websocket.WebSocketContainer; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.webapp.Configuration; import org.eclipse.jetty.ee9.webapp.Configurations; import org.eclipse.jetty.ee9.websocket.jakarta.client.JakartaWebSocketClientContainerProvider; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml index eef3def74100..10037cbff039 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/resources/jetty-websocket-httpclient.xml @@ -4,7 +4,7 @@ - + ws://localhost:/secured/socket diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/JettyUpgradeListener.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/JettyUpgradeListener.java index 6c2c222d7dc7..06975c97590e 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/JettyUpgradeListener.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/JettyUpgradeListener.java @@ -13,8 +13,8 @@ package org.eclipse.jetty.ee9.websocket.client; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; public interface JettyUpgradeListener { @@ -23,7 +23,7 @@ public interface JettyUpgradeListener * * @param request the request */ - default void onHandshakeRequest(HttpRequest request) + default void onHandshakeRequest(Request request) { } @@ -33,7 +33,7 @@ default void onHandshakeRequest(HttpRequest request) * @param request the request that was used * @param response the response that was received */ - default void onHandshakeResponse(HttpRequest request, HttpResponse response) + default void onHandshakeResponse(Request request, Response response) { } } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java index 7c287717f956..9d70f6eb01f2 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/WebSocketClient.java @@ -28,9 +28,8 @@ import java.util.function.Consumer; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.api.StatusCode; import org.eclipse.jetty.ee9.websocket.api.WebSocketBehavior; @@ -139,13 +138,13 @@ public CompletableFuture connect(Object websocket, URI toUri, ClientUpg upgradeRequest.addListener(new UpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { upgradeListener.onHandshakeRequest(request); } @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { upgradeListener.onHandshakeResponse(request, response); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java index b69895e2c773..2e4f8ff12433 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java @@ -34,7 +34,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; /** - * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpRequest} + * Representing the Jetty {@link org.eclipse.jetty.client.Request} * in the {@link UpgradeRequest} interface. */ public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest @@ -82,13 +82,13 @@ public Map> getHeaders() @Override public String getHost() { - return delegate.getHost(); + return delegate.getURI().getHost(); } @Override public String getHttpVersion() { - return delegate.getVersion().toString(); + return delegate.getVersion().asString(); } public void configure(EndPoint endpoint) @@ -127,7 +127,7 @@ public String getProtocolVersion() @Override public String getQueryString() { - return delegate.getQuery(); + return delegate.getURI().getRawQuery(); } @Override @@ -154,7 +154,7 @@ public boolean hasSubProtocol(String test) @Override public boolean isSecure() { - return HttpClient.isSchemeSecure(delegate.getScheme()); + return HttpClient.isSchemeSecure(delegate.getURI().getScheme()); } @Override diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index cc7e039cc86e..22994bcdbe41 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -20,20 +20,20 @@ import java.util.Set; import java.util.stream.Collectors; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.websocket.api.ExtensionConfig; import org.eclipse.jetty.ee9.websocket.api.UpgradeResponse; import org.eclipse.jetty.http.HttpHeader; /** - * Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse} + * Representing the Jetty {@link org.eclipse.jetty.client.Response} * in the {@link UpgradeResponse} interface. */ public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse { - private final HttpResponse delegate; + private final Response delegate; - public DelegatedJettyClientUpgradeResponse(HttpResponse response) + public DelegatedJettyClientUpgradeResponse(Response response) { this.delegate = response; } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/JettyClientUpgradeRequest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/JettyClientUpgradeRequest.java index 5fca8765f495..c6b8e79373e7 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/JettyClientUpgradeRequest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/JettyClientUpgradeRequest.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.ee9.websocket.common.JettyWebSocketFrameHandler; import org.eclipse.jetty.ee9.websocket.common.JettyWebSocketFrameHandlerFactory; @@ -57,7 +57,7 @@ public JettyClientUpgradeRequest(WebSocketCoreClient coreClient, ClientUpgradeRe } @Override - public void upgrade(HttpResponse response, EndPoint endPoint) + public void upgrade(Response response, EndPoint endPoint) { frameHandler.setUpgradeRequest(new DelegatedJettyClientUpgradeRequest(this)); frameHandler.setUpgradeResponse(new DelegatedJettyClientUpgradeResponse(response)); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/ConnectionHeaderTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/ConnectionHeaderTest.java index 1ccf6bd2e275..c38a48d680b8 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/ConnectionHeaderTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/ConnectionHeaderTest.java @@ -16,7 +16,7 @@ import java.net.URI; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.client.JettyUpgradeListener; @@ -74,7 +74,7 @@ public void testConnectionKeepAlive(String connectionHeaderValue) throws Excepti JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeRequest(HttpRequest request) + public void onHandshakeRequest(Request request) { HttpFields fields = request.getHeaders(); if (!(fields instanceof HttpFields.Mutable)) @@ -98,4 +98,4 @@ public void onHandshakeRequest(HttpRequest request) assertThat("Text Frame.status code", response, is(msg)); } } -} \ No newline at end of file +} diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyClientClassLoaderTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyClientClassLoaderTest.java index 60a18a5945e3..57cd40075eab 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyClientClassLoaderTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyClientClassLoaderTest.java @@ -23,9 +23,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.api.WebSocketPolicy; import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketConnect; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketExtensionConfigTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketExtensionConfigTest.java index 39cd6e1eff1c..69a63e1c4bb3 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketExtensionConfigTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketExtensionConfigTest.java @@ -19,8 +19,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.websocket.api.ExtensionConfig; import org.eclipse.jetty.ee9.websocket.api.Session; @@ -105,7 +105,7 @@ public void testJettyExtensionConfig() throws Exception JettyUpgradeListener listener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { String extensions = response.getHeaders().get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketNegotiationTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketNegotiationTest.java index 759956683ade..809252698656 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketNegotiationTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/JettyWebSocketNegotiationTest.java @@ -19,8 +19,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.client.ClientUpgradeRequest; @@ -130,21 +130,21 @@ public void testManualNegotiationInCreator() throws Exception URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/filterPath"); EventSocket socket = new EventSocket(); - AtomicReference responseReference = new AtomicReference<>(); + AtomicReference responseReference = new AtomicReference<>(); ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); upgradeRequest.addExtensions("permessage-deflate;client_no_context_takeover"); JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { responseReference.set(response); } }; client.connect(socket, uri, upgradeRequest, upgradeListener).get(5, TimeUnit.SECONDS); - HttpResponse httpResponse = responseReference.get(); - String extensions = httpResponse.getHeaders().get("Sec-WebSocket-Extensions"); + Response response = responseReference.get(); + String extensions = response.getHeaders().get("Sec-WebSocket-Extensions"); assertThat(extensions, is("permessage-deflate")); } } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java index 67b59074face..7164bea356f4 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java @@ -29,8 +29,8 @@ import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientConnectionFactory; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; import org.eclipse.jetty.ee9.nested.HttpChannel; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketServletExamplesTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketServletExamplesTest.java index 3a5af91345a8..99ec4260dc7c 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketServletExamplesTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketServletExamplesTest.java @@ -17,8 +17,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.AuthenticationStore; -import org.eclipse.jetty.client.util.BasicAuthentication; +import org.eclipse.jetty.client.AuthenticationStore; +import org.eclipse.jetty.client.BasicAuthentication; import org.eclipse.jetty.ee9.security.ConstraintMapping; import org.eclipse.jetty.ee9.security.ConstraintSecurityHandler; import org.eclipse.jetty.ee9.security.HashLoginService; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ConnectFutureTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ConnectFutureTest.java index 35adad831b71..8b317e79b6ef 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ConnectFutureTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ConnectFutureTest.java @@ -22,8 +22,8 @@ import java.util.concurrent.TimeoutException; import java.util.function.Consumer; -import org.eclipse.jetty.client.HttpRequest; -import org.eclipse.jetty.client.HttpResponse; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.websocket.api.Session; import org.eclipse.jetty.ee9.websocket.api.StatusCode; @@ -170,7 +170,7 @@ public void testAbortInHandshakeResponse() throws Exception JettyUpgradeListener upgradeListener = new JettyUpgradeListener() { @Override - public void onHandshakeResponse(HttpRequest request, HttpResponse response) + public void onHandshakeResponse(Request request, Response response) { try { @@ -373,4 +373,4 @@ public void onWebSocketConnect(Session session) assertThat(endpointError, instanceOf(WebSocketException.class)); assertThat(endpointError.getMessage(), is("custom exception")); } -} \ No newline at end of file +} diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java index 9c495cbdd894..caddb199f592 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.session.AbstractSessionTestBase; import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java index 02a59088dc3c..9a6226e1505d 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java @@ -19,9 +19,9 @@ import java.net.URLClassLoader; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.ee9.webapp.WebAppContext; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java index d74bd9f18345..51331c155089 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.memcached.sessions.MemcachedTestHelper.MockDataStore; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java index ed1a9c772505..416eb937725c 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredInvalidationSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredInvalidationSessionTest.java index 42490d7b1311..1a612c691d40 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredInvalidationSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredInvalidationSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredOrphanedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredOrphanedSessionTest.java index 7cf39495da68..c640954ed320 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredOrphanedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredOrphanedSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredSessionScavengingTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredSessionScavengingTest.java index be6d9391fb5c..bf4a64b25ca9 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredSessionScavengingTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractClusteredSessionScavengingTest.java @@ -26,13 +26,12 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.nested.SessionHandler; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; -import org.eclipse.jetty.session.AbstractSessionCache; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCache; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractWebAppObjectInSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractWebAppObjectInSessionTest.java index e088a2ceff7e..2dd01b01c32b 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractWebAppObjectInSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/main/java/org/eclipse/jetty/ee9/session/AbstractWebAppObjectInSessionTest.java @@ -18,9 +18,9 @@ import java.io.FileWriter; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.webapp.WebAppContext; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/AsyncTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/AsyncTest.java index 13e317966e37..50a0dd6236bc 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/AsyncTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/AsyncTest.java @@ -24,8 +24,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ClientCrossContextSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ClientCrossContextSessionTest.java index 3192732067e4..7de7a590b792 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ClientCrossContextSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ClientCrossContextSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ConcurrencyTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ConcurrencyTest.java index b576cd761879..597cd8b6e2e4 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ConcurrencyTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ConcurrencyTest.java @@ -25,9 +25,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.SessionCache; import org.eclipse.jetty.session.SessionDataStoreFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/CreationTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/CreationTest.java index 1e0097d549a1..570ad9b90cc5 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/CreationTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/CreationTest.java @@ -24,9 +24,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ListenerHolder; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DeleteUnloadableSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DeleteUnloadableSessionTest.java index 0b9cc0455b9b..a23ffcee36aa 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DeleteUnloadableSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DeleteUnloadableSessionTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.http.HttpField; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DuplicateCookieTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DuplicateCookieTest.java index 6eb5efb2d43b..b8a0cce6fabb 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DuplicateCookieTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/DuplicateCookieTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/IdleSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/IdleSessionTest.java index 180f13cb6340..ad491671e391 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/IdleSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/IdleSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ModifyMaxInactiveIntervalTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ModifyMaxInactiveIntervalTest.java index 924db4964de0..899cc4c5b3a6 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ModifyMaxInactiveIntervalTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ModifyMaxInactiveIntervalTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/NonClusteredSessionScavengingTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/NonClusteredSessionScavengingTest.java index 60e2e7993201..76aa3c3820d1 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/NonClusteredSessionScavengingTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/NonClusteredSessionScavengingTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RedirectSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RedirectSessionTest.java index e39598fcc800..b0b715f231df 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RedirectSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RedirectSessionTest.java @@ -20,8 +20,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.SessionCache; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ReentrantRequestSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ReentrantRequestSessionTest.java index 8df57494c8fe..a0352f09f121 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ReentrantRequestSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/ReentrantRequestSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.NullSessionDataStoreFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RemoveSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RemoveSessionTest.java index c6d8948f78cc..04712aaa4299 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RemoveSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RemoveSessionTest.java @@ -22,9 +22,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.nested.SessionHandler; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.AbstractSessionCache; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestDispatchedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestDispatchedSessionTest.java index 7b735f27dfb4..c3beba00daf5 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestDispatchedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestDispatchedSessionTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.FormRequestContent; import org.eclipse.jetty.ee9.servlet.DefaultServlet; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.http.HttpMethod; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestScopedSessionSaveTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestScopedSessionSaveTest.java index 1ffdae3605a9..87e2e9085fd0 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestScopedSessionSaveTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/RequestScopedSessionSaveTest.java @@ -24,15 +24,13 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.ee9.nested.ContextHandler; import org.eclipse.jetty.ee9.nested.ContextHandler.APIContext; import org.eclipse.jetty.ee9.nested.ContextHandler.ContextScopeListener; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.logging.StacklessLogging; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.session.AbstractSessionDataStore; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SameContextForwardedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SameContextForwardedSessionTest.java index 269c812e809e..a58ff3f2c6c3 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SameContextForwardedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SameContextForwardedSessionTest.java @@ -21,9 +21,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.session.DefaultSessionCacheFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidateCreateScavengeTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidateCreateScavengeTest.java index 12321bee6840..31f8aefac202 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidateCreateScavengeTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidateCreateScavengeTest.java @@ -28,9 +28,9 @@ import jakarta.servlet.http.HttpSessionBindingListener; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidationTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidationTest.java index e7a92694d8d0..48f8e82f14cb 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidationTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionInvalidationTest.java @@ -20,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionRenewTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionRenewTest.java index 8d53ea132069..4af46a26e5b9 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionRenewTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-sessions-common/src/test/java/org/eclipse/jetty/ee9/session/SessionRenewTest.java @@ -24,9 +24,9 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSessionEvent; import jakarta.servlet.http.HttpSessionIdListener; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.ee9.nested.SessionHandler.ServletAPISession; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.session.DefaultSessionCache; diff --git a/pom.xml b/pom.xml index 8885d0c3b459..0e9af782f6e1 100644 --- a/pom.xml +++ b/pom.xml @@ -106,16 +106,39 @@ 3.8.4 0.13.1 1.9.2 - 3.8.6 + 3.8.7 3.12.11 0.9.1 8.1.0 6.0.0 1.2.0 1.2.0 + + 3.18.200 + + 8.1.0 + 3.11.100 + 1.6.1 + 1.5.0 + 1.4.1 + 3.7.100 + 1.2.0 + 1.2.0 + 1.0.2 + 1.0.1 + 1.5.4 + 1.0.2 + 1.0.0-v20070606 + 4.13.1 + 2.6.2 + 1.8.3 + 3.0.0 + 1.2 + 2.1.1 3.5.0 2.0.5 + 1.3.6 2.1.1.RELEASE 1.2.5 1.2.5 @@ -272,12 +295,12 @@ [ERROR] OLD JDK [${java.version}] in use. Jetty ${project.version} requires JDK 17 or newer - - - + + + @@ -1058,6 +1081,11 @@ ant-launcher ${ant.version}
+ + org.apache.aries.spifly + org.apache.aries.spifly.dynamic.bundle + ${spifly.version} + org.apache.commons commons-lang3 @@ -1068,6 +1096,11 @@ org.apache.felix.framework ${felix.version} + + org.apache.geronimo.specs + geronimo-atinject_1.0_spec + ${injection.bundle.version} + org.apache.kerby kerb-simplekdc @@ -1536,6 +1569,88 @@ ${jetty.xhtml.schemas-version} test + + org.eclipse.platform + org.eclipse.osgi.services + ${osgi-services-version} + + + + jakarta.servlet + servlet-api + + + + org.apache.felix + org.osgi.foundation + + + + + + org.eclipse.platform + org.eclipse.osgi + ${osgi-version} + + + org.eclipse.platform + org.eclipse.osgi.util + ${osgi-util-version} + + + org.osgi + org.osgi.service.cm + ${osgi-service-cm-version} + + + org.osgi + osgi.annotation + ${osgi-annotation-version} + + + org.osgi + org.osgi.service.component + ${osgi-service-component-version} + + + org.osgi + org.osgi.service.event + ${osgi-service-event-version} + + + org.osgi + org.osgi.util.tracker + ${osgi-util-tracker-version} + + + org.osgi + org.osgi.util.promise + ${osgi-util-promise-version} + test + + + org.osgi + org.osgi.util.measurement + ${osgi-util-measurement-version} + test + + + org.osgi + org.osgi.util.position + ${osgi-util-position-version} + test + + + org.osgi + org.osgi.util.xml + ${osgi-util-xml-version} + test + + + org.eclipse.equinox.http + servlet + ${equinox-http-servlet-version} + org.hamcrest hamcrest @@ -1602,6 +1717,59 @@ jetty-quiche-native ${jetty-quiche-native.version} + + + + org.ops4j.pax.exam + pax-exam + ${pax.exam.version} + + + org.ops4j.pax.exam + pax-exam-inject + ${pax.exam.version} + + + org.ops4j.pax.exam + pax-exam-container-forked + ${pax.exam.version} + + + org.ops4j.pax.tinybundles + tinybundles + ${tinybundles.version} + + + org.ops4j.pax.swissbox + pax-swissbox-framework + ${swissbox.version} + + + org.ops4j.pax.swissbox + pax-swissbox-tracker + ${swissbox.version} + + + org.ops4j.pax.exam + pax-exam-junit4 + ${pax.exam.version} + + + org.ops4j.pax.exam + pax-exam-link-mvn + ${pax.exam.version} + + + org.ops4j.pax.url + pax-url-aether + ${pax.url.version} + + + org.ops4j.pax.url + pax-url-wrap + ${pax.url.version} + + org.osgi diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/AbstractJettyHomeTest.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/AbstractJettyHomeTest.java index e3ad32c7ed16..9e35152a2e35 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/AbstractJettyHomeTest.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/AbstractJettyHomeTest.java @@ -18,9 +18,9 @@ import java.nio.file.Path; import java.util.function.Supplier; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/BadAppTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/BadAppTests.java index 96538dd75bf2..4cbd9920f2f4 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/BadAppTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/BadAppTests.java @@ -16,7 +16,7 @@ import java.io.File; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.junit.jupiter.params.ParameterizedTest; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/CDITests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/CDITests.java index 19af6fbfdefc..e8a33cab58e4 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/CDITests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/CDITests.java @@ -23,7 +23,7 @@ import java.util.function.Consumer; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.eclipse.jetty.util.StringUtil; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java index 2cee056e4b00..e9cd3df3f7b4 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.util.FormRequestContent; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.FormRequestContent; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.eclipse.jetty.util.Fields; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index 575b1490a1f8..955dbf9deed2 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -31,10 +31,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportDynamic; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http2.client.HTTP2Client; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java index 9a04be98c125..3cb113f8dae2 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java @@ -19,7 +19,7 @@ import java.nio.file.Paths; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.eclipse.jetty.util.IO; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java index 1b2d57d368b4..fd4383d8ff85 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java @@ -17,7 +17,7 @@ import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java index 007b27e55204..dad9b8336396 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; import java.util.stream.Stream; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.junit.jupiter.api.Disabled; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/OsgiAppTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/OsgiAppTests.java index a3379d400da9..519708cbe09f 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/OsgiAppTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/OsgiAppTests.java @@ -16,7 +16,7 @@ import java.io.File; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.junit.jupiter.params.ParameterizedTest; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/StatsTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/StatsTests.java index 971e9f418608..c6ec583e2d11 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/StatsTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/StatsTests.java @@ -21,7 +21,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java index 952590ce1f26..13d51689427c 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest; import org.eclipse.jetty.tests.hometester.JettyHomeTester; diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java index cf113ea0155f..7167dc864992 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java @@ -27,7 +27,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.hometester.JettyHomeTester; import org.junit.jupiter.api.Disabled; diff --git a/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java b/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java index 64c82d646f83..45ccc730bf62 100644 --- a/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java +++ b/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java @@ -17,7 +17,7 @@ import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.ee10.tests.distribution.openid.OpenIdProvider; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest; diff --git a/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java b/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java index 7a5c9baaf4ab..3ab042b0dba3 100644 --- a/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java +++ b/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java @@ -17,7 +17,7 @@ import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.ee9.tests.distribution.openid.OpenIdProvider; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest; diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerMultipleResourceBasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerMultipleResourceBasesTest.java index 10a6009c2c8b..4309d2e697a2 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerMultipleResourceBasesTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerMultipleResourceBasesTest.java @@ -19,8 +19,8 @@ import java.nio.file.Files; import java.nio.file.Path; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.AliasCheck; import org.eclipse.jetty.server.Handler; diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerSymlinkTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerSymlinkTest.java index 12a6cb2d61c9..ea762092ab1c 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerSymlinkTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/AliasCheckerSymlinkTest.java @@ -20,8 +20,8 @@ import java.nio.file.Path; import java.util.stream.Stream; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.AliasCheck; import org.eclipse.jetty.server.AllowedResourceAliasChecker;
Next Chunk