Skip to content

Commit

Permalink
Renamed HttpClient.getTransport() to `HttpClient.getHttpClientTrans…
Browse files Browse the repository at this point in the history
…port()`.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Dec 2, 2024
1 parent 2e5e47d commit 2a40114
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ public void setConnectionPool() throws Exception
// the transport supports multiplexing requests on the same connection.
int maxRequestsPerConnection = 1;

HttpClientTransport transport = httpClient.getTransport();
HttpClientTransport transport = httpClient.getHttpClientTransport();

// Set the ConnectionPool.Factory using a lambda.
transport.setConnectionPoolFactory(destination ->
Expand All @@ -1087,7 +1087,7 @@ public void preCreateConnections() throws Exception
httpClient.start();

// For HTTP/1.1, you need to explicitly configure to initialize connections.
if (httpClient.getTransport() instanceof HttpClientTransportOverHTTP http1)
if (httpClient.getHttpClientTransport() instanceof HttpClientTransportOverHTTP http1)
http1.setInitializeConnections(true);

// Create a dummy request to the server you want to pre-create connections to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,19 @@ public HttpClient(HttpClientTransport transport)
installBean(decoderFactories);
}

/**
* @deprecated use {@link #getHttpClientTransport()} instead
*/
@Deprecated(forRemoval = true, since = "12.1.0")
public HttpClientTransport getTransport()
{
return getHttpClientTransport();
}

/**
* @return the {@link HttpClientTransport} associated with this {@code HttpClient}
*/
public HttpClientTransport getHttpClientTransport()
{
return transport;
}
Expand Down Expand Up @@ -451,7 +463,7 @@ private HttpRequest newHttpRequest(HttpConversation conversation, URI uri)

public Destination resolveDestination(Request request)
{
HttpClientTransport transport = getTransport();
HttpClientTransport transport = getHttpClientTransport();
Origin origin = transport.newOrigin(request);
Destination destination = resolveDestination(origin);
if (LOG.isDebugEnabled())
Expand Down Expand Up @@ -488,7 +500,7 @@ public Destination resolveDestination(Origin origin)
{
if (v == null || v.stale())
{
HttpDestination newDestination = (HttpDestination)getTransport().newDestination(k);
HttpDestination newDestination = (HttpDestination)getHttpClientTransport().newDestination(k);
// Start the destination before it's published to other threads.
addManaged(newDestination);
if (destinationSweeper != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public HttpDestination(HttpClient client, Origin origin)
host += ":" + port;
hostField = new HttpField(HttpHeader.HOST, host);

ClientConnectionFactory connectionFactory = client.getTransport();
ClientConnectionFactory connectionFactory = client.getHttpClientTransport();
boolean intrinsicallySecure = origin.getTransport().isIntrinsicallySecure();

ProxyConfiguration proxyConfig = client.getProxyConfiguration();
Expand Down Expand Up @@ -186,7 +186,7 @@ protected void doStop() throws Exception

protected ConnectionPool newConnectionPool(HttpClient client)
{
return client.getTransport().getConnectionPoolFactory().newConnectionPool(this);
return client.getHttpClientTransport().getConnectionPoolFactory().newConnectionPool(this);
}

protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public HttpReceiverOverHTTP(HttpChannelOverHTTP channel)
super(channel);
HttpClient httpClient = channel.getHttpDestination().getHttpClient();
parser = new HttpParser(this, httpClient.getMaxResponseHeadersSize(), httpClient.getHttpCompliance());
HttpClientTransport transport = httpClient.getTransport();
HttpClientTransport transport = httpClient.getHttpClientTransport();
if (transport instanceof HttpClientTransportOverHTTP httpTransport)
{
parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void upgrade(Response response, EndPoint endPoint, Callback callback)
if (response.getHeaders().contains(HttpHeader.UPGRADE, protocol))
{
HttpClient httpClient = destination.getHttpClient();
HttpClientTransport transport = httpClient.getTransport();
HttpClientTransport transport = httpClient.getHttpClientTransport();
if (transport instanceof HttpClientTransportDynamic)
{
HttpClientTransportDynamic dynamicTransport = (HttpClientTransportDynamic)transport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool
}

// Give a chance to the transport implementation to customize the FastCGI headers
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getTransport();
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getHttpClientTransport();
transport.customize(request, fcgiHeaders);

ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public boolean handle(Request request, org.eclipse.jetty.server.Response respons

httpClient.setMaxConnectionsPerDestination(32768);
httpClient.setMaxRequestsQueuedPerDestination(1024 * 1024);
httpClient.getTransport().setConnectionPoolFactory(destination ->
httpClient.getHttpClientTransport().setConnectionPoolFactory(destination ->
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testPreCreateConnections(Transport transport) throws Exception
startClient(transport);
client.setMaxConnectionsPerDestination(maxConnectionsPerDestination);
if (transport == Transport.HTTPS)
((HttpClientTransportOverHTTP)client.getTransport()).setInitializeConnections(true);
((HttpClientTransportOverHTTP)client.getHttpClientTransport()).setInitializeConnections(true);

var request = client.newRequest(newURI(transport));
Destination destination = client.resolveDestination(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testDefaultTransport() throws Exception
Destination destination = destinations.get(0);
assertThat(destination.getOrigin().getTransport(), sameInstance(Transport.TCP_IP));

HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getTransport();
HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getTransport();
HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testDefaultTransport() throws Exception
Destination destination = destinations.get(0);
assertThat(destination.getOrigin().getTransport(), sameInstance(Transport.TCP_IP));

HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getHTTP2Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getHTTP2Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public void testQUICTransportWithH2(WorkDir workDir) throws Exception

SslContextFactory.Client sslClient = new SslContextFactory.Client(true);
httpClient.setSslContextFactory(sslClient);
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
// ALPN is negotiated by QUIC.
httpClientTransport.setUseALPN(false);
ClientQuicConfiguration clientQuicConfig = new ClientQuicConfiguration(sslClient, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testDefaultTransport() throws Exception
transport = wrapper.unwrap();
assertThat(transport, sameInstance(Transport.UDP_IP));

HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getTransport();
HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getHTTP3Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getTransport();
HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getHttpClientTransport();
int networkConnections = httpClientTransport.getHTTP3Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ public boolean handle(Request request, org.eclipse.jetty.server.Response respons
// - the connection can be used by two concurrent requests;
// - the connection is pre-created.
client.setMaxConnectionsPerDestination(1);
client.getTransport().setConnectionPoolFactory(destination ->
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
{
MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, 1, 2);
LifeCycle.start(pool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean handle(Request request, Response response, Callback callback)

int maxConnections = 3;
CompletableFuture<Void> setup = new CompletableFuture<>();
client.getTransport().setConnectionPoolFactory(destination ->
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections);
LifeCycle.start(pool);
Expand Down Expand Up @@ -146,7 +146,7 @@ public boolean handle(Request request, Response response, Callback callback)
});

CompletableFuture<Void> setup = new CompletableFuture<>();
client.getTransport().setConnectionPoolFactory(destination ->
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections);
LifeCycle.start(pool);
Expand Down Expand Up @@ -226,7 +226,7 @@ public boolean handle(Request request, Response response, Callback callback)
});
if (transport == Transport.H3)
((QuicServerConnector)connector).getQuicConfiguration().setMaxBidirectionalRemoteStreams(maxUsage);
client.getTransport().setConnectionPoolFactory(destination ->
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, maxMultiplex);
pool.setMaxUsage(maxUsage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void testTLSWrapFailure(Transport transport, TLSHandshakeAction action,
{
start(transport, new EmptyServerHandler());
client.stop();
client = new HttpClient(client.getTransport())
client = new HttpClient(client.getHttpClientTransport())
{
@Override
public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
Expand Down Expand Up @@ -163,7 +163,7 @@ private void testTLSUnwrapFailure(Transport transport, TLSHandshakeAction action
{
start(transport, new EmptyServerHandler());
client.stop();
client = new HttpClient(client.getTransport())
client = new HttpClient(client.getHttpClientTransport())
{
@Override
public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down

0 comments on commit 2a40114

Please sign in to comment.