APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http

pack-priv final Class HttpClientImpl

extends HttpClient
implements Trackable
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.common.OperationTrackers.Trackable
Imports
javax.net.ssl.SSLContext, .SSLException, .SSLHandshakeException, .SSLParameters, java.io.IOException, .UncheckedIOException, java.lang.ref.Reference, .WeakReference, java.net.Authenticator, .ConnectException, .CookieHandler, .InetAddress, .ProtocolException, .ProxySelector, java.net.http.HttpConnectTimeoutException, .HttpTimeoutException, .UnsupportedProtocolVersionException, .HttpClient, .HttpRequest, .HttpResponse, .HttpResponse.BodyHandler, .HttpResponse.PushPromiseHandler, .WebSocket, java.nio.ByteBuffer, java.nio.channels.CancelledKeyException, .ClosedChannelException, .ClosedSelectorException, .SelectableChannel, .SelectionKey, .Selector, java.security.NoSuchAlgorithmException, java.time.Duration, java.time.temporal.ChronoUnit, java.util.ArrayList, .Arrays, .HashSet, .Iterator, .List, .Objects, .Optional, .Set, .TreeSet, java.util.concurrent.CancellationException, .CompletableFuture, .ConcurrentSkipListSet, .ExecutionException, .Executor, .ExecutorService, .Executors, .RejectedExecutionException, .ThreadFactory, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicLong, .AtomicReference, java.util.concurrent.locks.ReentrantLock, java.util.function.BiConsumer, .BooleanSupplier, .Function, java.util.stream.Stream, jdk.internal.net.http.common.BufferSupplier, .Deadline, .HttpBodySubscriberWrapper, .Log, .Logger, .MinimalFuture, .Pair, .TimeSource, .Utils, .OperationTrackers.Trackable, .OperationTrackers.Tracker, .Utils.SafeExecutor, .Utils.SafeExecutorService, .Utils.UseVTForSelector, jdk.internal.net.http.websocket.BuilderImpl

Client implementation. Contains all configuration information and also the selector manager thread which allows async events to be registered and delivered when they occur. See AsyncEvent.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
HttpClientImpl.DelegatingExecutor

A DelegatingExecutor is an executor that delegates tasks to a wrapped executor when it detects that the current thread is the SelectorManager thread.

pack-priv static class
private static class
private static class
HttpClientImpl.SelectorAttachment

Tracks multiple user level registrations associated with one NIO registration (SelectionKey).

private static class
private static class
HttpClientImpl.SingleFacadeFactory

This is a bit tricky: 1.

private static class

Field Summary

Modifier and TypeField and Description
private static final Executor
private final Authenticator
private final Http2ClientImpl
private final Http3ClientImpl
pack-priv static final AtomicLong
private final AtomicLong
private final ConnectionPool
private final Duration
private final CookieHandler
private final String
pack-priv final Logger
pack-priv static final boolean
pack-priv final Logger
pack-priv static final boolean
pack-priv final Logger
pack-priv static final int
private final HttpClientImpl.DelegatingExecutor
private final WeakReference<HttpClientFacade>
private final FilterFactory
private final HttpClient.Redirect
private final boolean
private final boolean
private final long
pack-priv static final long
pack-priv static final long
private final WeakReference<HttpClientImpl>
private final AtomicBoolean
private final boolean
private final AtomicBoolean
pack-priv static final long
private final InetAddress
private final ConcurrentSkipListSet<PlainHttpConnection>
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final Set<HttpClientImpl.PendingRequest>
private final AtomicLong
private final AtomicLong
private final AtomicLong
private final ProxySelector
private final AltServicesRegistry
private final HttpClientImpl.SelectorManager
private final Thread
private volatile boolean
private final HttpClientImpl.SSLDirectBufferSupplier
private final SSLContext
private final SSLParameters
private final ConcurrentSkipListSet<HttpBodySubscriberWrapper<?>>
private final TreeSet<TimeoutEvent>
timeouts

A Set of, deadline first, ordered timeout events.

pack-priv static final Utils.UseVTForSelector
private final ProxySelector
private final HttpClient.Version

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
private void
public Optional<Authenticator>
authenticator()

Implements abstract java.net.http.HttpClient.authenticator.

Returns an Optional containing the Authenticator set on this client.

public boolean
awaitTermination(Duration duration)

Overrides java.net.http.HttpClient.awaitTermination.

Blocks until all operations have completed execution after a shutdown request, or the duration elapses, or the current thread is interrupted, whichever happens first.

pack-priv void
pack-priv Http2ClientImpl
pack-priv Optional<Http3ClientImpl>
private void
private void
private static void
public void
public void
pack-priv ConnectionPool
public Optional<Duration>
connectTimeout()

Implements abstract java.net.http.HttpClient.connectTimeout.

Returns an Optional containing the connect timeout duration for this client.

public Optional<CookieHandler>
cookieHandler()

Implements abstract java.net.http.HttpClient.cookieHandler.

Returns an Optional containing this client's CookieHandler.

pack-priv static HttpClientFacade
pack-priv String
private void
debugCompleted(String tag, long startNanos, HttpRequest req)

pack-priv final String
pack-priv void
eventUpdated(AsyncEvent
The modified event.
event
)

Allows an AsyncEvent to modify its interestOps.

public final Optional<Executor>
executor()

Implements abstract java.net.http.HttpClient.executor.

Returns an Optional containing this client's Executor.

pack-priv final HttpClientFacade
pack-priv void
pack-priv final List<HeaderFilter>
pack-priv boolean
public HttpClient.Redirect
followRedirects()

Implements abstract java.net.http.HttpClient.followRedirects.

Returns the follow redirects policy for this client.

public OperationTrackers.Tracker
pack-priv int
pack-priv int
pack-priv BufferSupplier
private static long
getTimeoutProp(String prop, long def)

pack-priv final long
pack-priv final long
pack-priv boolean
hasRequiredHTTP2TLSVersion()

Returns true if the SSL parameter protocols contains at least one TLS version that HTTP/2 requires.

pack-priv boolean
hasRequiredHTTP3TLSVersion()

Returns true if the SSL parameter protocols contains at least one TLS version that HTTP/3 requires.

pack-priv Optional<Duration>
private void
private boolean
pack-priv boolean
pack-priv boolean
public boolean
isTerminated()

Overrides java.net.http.HttpClient.isTerminated.

Returns true if all operations have completed following a shutdown.

pack-priv InetAddress
public long
public WebSocket.Builder
newWebSocketBuilder()

Overrides java.net.http.HttpClient.newWebSocketBuilder.

Creates a new WebSocket builder (optional operation).

pack-priv void
public Optional<ProxySelector>
proxy()

Implements abstract java.net.http.HttpClient.proxy.

Returns an Optional containing the ProxySelector supplied to this client.

pack-priv ProxySelector
private long
purgeTimeoutsAndReturnNextDeadline()

Purges ( handles ) timer events that have passed their deadline, and returns the amount of time, in milliseconds, until the next earliest event.

pack-priv final long
pack-priv final long
pack-priv void
registerEvent(AsyncEvent exchange)

Wait for activity on given exchange.

pack-priv static <T> CompletableFuture<T>
public boolean

Returns:

true if the subscriber was added to the list.
registerSubscriber
(HttpBodySubscriberWrapper<?>
the subscriber
subscriber
)

Adds the given subscriber to the subscribers list, or call its onError method if the client is shutting down.

pack-priv void
pack-priv AltServicesRegistry
pack-priv final long
pack-priv final long
pack-priv IOException
public <T> HttpResponse<T>
send(HttpRequest req, HttpResponse.BodyHandler<T> responseHandler)

Implements abstract java.net.http.HttpClient.send.

Sends the given request using this client, blocking if necessary to get the response.

public <T> CompletableFuture<HttpResponse<T>>
sendAsync(HttpRequest userRequest, HttpResponse.BodyHandler<T> responseHandler)

Implements abstract java.net.http.HttpClient.sendAsync.

Sends the given request asynchronously using this client with the given response body handler.

public <T> CompletableFuture<HttpResponse<T>>
sendAsync(HttpRequest userRequest, HttpResponse.BodyHandler<T> responseHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler)

Implements abstract java.net.http.HttpClient.sendAsync.

Sends the given request asynchronously using this client with the given response body handler and push promise handler.

private <T> CompletableFuture<HttpResponse<T>>
sendAsync(HttpRequest userRequest, HttpResponse.BodyHandler<T> responseHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler, Executor exchangeExecutor)

public void
shutdown()

Overrides java.net.http.HttpClient.shutdown.

Initiates an orderly shutdown in which requests previously submitted with send or sendAsync are run to completion, but no new request will be accepted.

public void
shutdownNow()

Overrides java.net.http.HttpClient.shutdownNow.

This method attempts to initiate an immediate shutdown.

public SSLContext
sslContext()

Implements abstract java.net.http.HttpClient.sslContext.

Returns this client's SSLContext.

public SSLParameters
sslParameters()

Implements abstract java.net.http.HttpClient.sslParameters.

Returns a copy of this client's SSLParameters.

private void
private void
stop()

pack-priv final long
pack-priv final long
pack-priv final HttpClientImpl.DelegatingExecutor
pack-priv SSLContext
private Optional<Duration>
timeoutDuration(long seconds)

pack-priv List<TimeoutEvent>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static <T> CompletableFuture<HttpResponse<T>>

Returns:

a new CompletableFuture wrapping the sendAsync() execution failures with, as per specification, IOException, if necessary
translateSendAsyncExecFailure
(CompletableFuture<HttpResponse<T>> responseFuture)

Returns a new CompletableFuture wrapping the sendAsync() execution failures with, as per specification, IOException, if necessary.

pack-priv final long
public boolean

Returns:

true if the subscriber was found and removed from the list.
unregisterSubscriber
(HttpBodySubscriberWrapper<?>
the subscriber
subscriber
)

Remove the given subscriber from the subscribers list.

private static boolean
public HttpClient.Version
version()

Implements abstract java.net.http.HttpClient.version.

Returns the preferred HTTP protocol version for this client.

pack-priv final long
pack-priv final long
Inherited from java.net.http.HttpClient:
closenewBuildernewHttpClient