Skip to content

Commit

Permalink
Merge branch 'jetty-12.0.x' of https://github.com/eclipse/jetty.project
Browse files Browse the repository at this point in the history
… into jetty-12.0.x-documentation-lowercase-jetty_home-attribute

* 'jetty-12.0.x' of https://github.com/eclipse/jetty.project:
  Issue jetty#9167 - making assumption in flaky test
  jetty 12.0.x cleanup duplicate osgi pom metadata (jetty#9093)
  Jetty 12 - Add tests in util/resource for alternate FileSystem implementations (jetty#9149)
  Cleanup non-retainable `Retainable`s (jetty#9159)
  Fixes retainability of special Chunks (jetty#9073)
  TCK: Dispatch forward and includes attributes do not meet the spec (jetty#9074)
  re-enable h3 tests (jetty#8773)
  More fundamental test case
  Reorganization of jetty-client classes. (jetty#9127)
  Removing @disabled from SslUploadTest
  Removing @disabled from jetty-start
  Bump maven.version from 3.8.6 to 3.8.7
  Bump maven.version from 3.8.6 to 3.8.7
  • Loading branch information
Greg Poulos committed Jan 16, 2023
2 parents e765713 + be3b8f0 commit 4b5c40d
Show file tree
Hide file tree
Showing 554 changed files with 3,898 additions and 3,668 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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[]
}
Expand All @@ -901,7 +895,6 @@ public void setConnectionPool() throws Exception
transport.setConnectionPoolFactory(destination ->
new RoundRobinConnectionPool(destination,
maxConnectionsPerDestination,
destination,
maxRequestsPerConnection));
// end::setConnectionPool[]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions jetty-core/jetty-client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Connection> pool;
private boolean maximizeConnections;
private volatile long maxDurationNanos;
private volatile int maxUsage;
private volatile int initialMaxMultiplex;

protected AbstractConnectionPool(HttpDestination destination, Pool<Connection> pool, Callback requester, int initialMaxMultiplex)
protected AbstractConnectionPool(Destination destination, Pool<Connection> pool, int initialMaxMultiplex)
{
this.destination = destination;
this.requester = requester;
this.destination = (HttpDestination)destination;
this.pool = pool;
this.initialMaxMultiplex = initialMaxMultiplex;
addBean(pool);
Expand Down Expand Up @@ -307,7 +304,7 @@ public boolean accept(Connection connection)

protected void proceed()
{
requester.succeeded();
destination.succeeded();
}

protected Connection activate()
Expand Down Expand Up @@ -587,7 +584,7 @@ public void failed(Throwable x)
pending.decrementAndGet();
reserved.remove();
completeExceptionally(x);
requester.failed(x);
destination.failed(x);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.client.api;
package org.eclipse.jetty.client;

import java.net.URI;
import java.util.Map;
Expand Down Expand Up @@ -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)}.
* <p>
* 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
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("(?<schemeOnly>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?<scheme>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?<token68>[a-zA-Z0-9\\-._~+/]+=*)|(?<paramName>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:(?<paramValue>.*)))");

private final HttpClient client;
private final int maxContentLength;
private final ResponseNotifier notifier;

private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(?<schemeOnly>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?<scheme>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?<token68>[a-zA-Z0-9\\-._~+/]+=*)|(?<paramName>[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:(?<paramValue>.*)))");

protected AuthenticationProtocolHandler(HttpClient client, int maxContentLength)
{
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.client.api;
package org.eclipse.jetty.client;

import java.net.URI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,7 +64,7 @@ public Result authenticate(Request request, ContentResponse response, HeaderInfo
* Basic authentication result.
* <p>
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.client.util;
package org.eclipse.jetty.client;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Loading

0 comments on commit 4b5c40d

Please sign in to comment.