Top Description Inners Fields Constructors Methods
jdk.internal.net.http

pack-priv Class Http1Exchange<T>

extends ExchangeImpl<T>
Class Inheritance
Imports
java.io.IOException, java.net.InetSocketAddress, java.net.http.HttpResponse, .HttpResponse.BodyHandler, .HttpResponse.BodySubscriber, .HttpResponse.ResponseInfo, java.nio.ByteBuffer, java.util.Objects, .LinkedList, .List, java.util.concurrent.CompletableFuture, .ConcurrentLinkedDeque, .Executor, .Flow, java.util.concurrent.atomic.AtomicReference, java.util.concurrent.locks.ReentrantLock, jdk.internal.net.http.common.Demand, .HttpBodySubscriberWrapper, .Log, .FlowTube, .Logger, .SequentialScheduler, .MinimalFuture, .Utils

Encapsulates one HTTP/1.1 request/response exchange.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Http1Exchange.DataPair

A carrier for either data or an error.

pack-priv class
Http1Exchange.Http1Publisher

A Publisher of HTTP/1.1 headers and request body.

pack-priv abstract static class
Http1Exchange.Http1RequestBodySubscriber

An abstract supertype for HTTP/1.1 body subscribers.

pack-priv static class
Http1Exchange.Http1ResponseBodySubscriber<
The type of response.
U
>

The Http1AsyncReceiver ensures that all calls to the subscriber, including onSubscribe, occur sequentially.

pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final Http1AsyncReceiver
private final CompletableFuture<ExchangeImpl<T>>
bodySentCF

Completed when the body has been published, or there is an error

private volatile Http1Exchange.Http1RequestBodySubscriber
bodySubscriber

The subscriber to the request's body published.

pack-priv final HttpClientImpl
pack-priv final HttpConnection
pack-priv final Logger
pack-priv final Executor
private final AtomicReference<Throwable>
failedRef

Records a possible cancellation raised before any operation has been initiated, or an error received while sending the request.

private final CompletableFuture<ExchangeImpl<T>>
headersSentCF

Completed when the header have been published, or there is an error

private final ReentrantLock
lock

Must be held when operating on any internal state or data.

private final List<CompletableFuture<?>>
pack-priv final ConcurrentLinkedDeque<Http1Exchange.DataPair>
outgoing

Holds the outgoing data, either the headers or a request body part.

pack-priv final HttpRequestImpl
pack-priv final Http1Request
private volatile Http1Response<T>
private volatile HttpResponse.BodySubscriber<T>
responseSubscriber

The subscriber to the response's body received.

private Http1Exchange.State
private volatile boolean
private final Http1Exchange<T>.Http1Publisher
writePublisher

The write publisher, responsible for writing the complete request ( both headers and body ( if any )).

Inherited from jdk.internal.net.http.ExchangeImpl:
exchange

Constructor Summary

AccessConstructor and Description
pack-priv
Http1Exchange(Exchange<T> exchange, HttpConnection connection)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
appendToOutgoing(Throwable throwable)

Convenience for appendToOutgoing(DataPair), with just a Throwable.

pack-priv void
appendToOutgoing(List<ByteBuffer> item)

Convenience for appendToOutgoing(DataPair), with just data.

private void
pack-priv void
cancel()

Implements abstract jdk.internal.net.http.ExchangeImpl.cancel.

Cancel checks to see if request and responseAsync finished already.
pack-priv void
cancel(IOException cause)

Implements abstract jdk.internal.net.http.ExchangeImpl.cancel.

Cancel checks to see if request and responseAsync finished already.
private void
private void
private void
pack-priv final HttpClientImpl
pack-priv void
completed()

Implements abstract jdk.internal.net.http.ExchangeImpl.completed.

Called when the exchange is completed, so that cleanup actions may be performed - such as deregistering callbacks.
private void
pack-priv HttpConnection
connection()

Implements abstract jdk.internal.net.http.ExchangeImpl.connection.

Returns the HttpConnection instance to which this exchange is assigned.
pack-priv Http1Exchange.Http1ResponseBodySubscriber<T>
pack-priv String
pack-priv ByteBuffer
pack-priv void
pack-priv Throwable
getCancelCause()

Implements abstract jdk.internal.net.http.ExchangeImpl.getCancelCause.

Returns the cause for which this exchange was canceled, if available.
private Http1Exchange.DataPair
getOutgoing()

Returns the next portion of the HTTP request, or the error.

pack-priv CompletableFuture<Response>
getResponseAsync(Executor executor)

Implements abstract jdk.internal.net.http.ExchangeImpl.getResponseAsync.

Gets the response headers.
private boolean
hasOutgoing()

Tells whether, or not, there is any outgoing data that can be published, or if there is an error.

pack-priv CompletableFuture<Void>
ignoreBody()

Implements abstract jdk.internal.net.http.ExchangeImpl.ignoreBody.

Ignore/consume the body.
pack-priv boolean
isCanceled()

Implements abstract jdk.internal.net.http.ExchangeImpl.isCanceled.

Returns true if this exchange was canceled.
public void
pack-priv void
onProtocolError(final IOException
The cause of the protocol violation
cause
)

Implements abstract jdk.internal.net.http.ExchangeImpl.onProtocolError.

Invoked whenever there is a (HTTP) protocol error when dealing with the response from the server.
pack-priv CompletableFuture<T>
readBodyAsync(HttpResponse.BodyHandler<T> handler, boolean returnConnectionToPool, Executor executor)

Implements abstract jdk.internal.net.http.ExchangeImpl.readBodyAsync.

private boolean
pack-priv void
released()

Implements abstract jdk.internal.net.http.ExchangeImpl.released.

Called when the exchange is released, so that cleanup actions may be performed - such as deregistering callbacks.
pack-priv HttpRequestImpl
private void
private void
pack-priv CompletableFuture<ExchangeImpl<T>>
sendBodyAsync()

Implements abstract jdk.internal.net.http.ExchangeImpl.sendBodyAsync.

Sends a request body, after request headers have been sent.
pack-priv CompletableFuture<ExchangeImpl<T>>
pack-priv Http1Exchange.State
pack-priv Http1Exchange.State
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private boolean
pack-priv void
Inherited from jdk.internal.net.http.ExchangeImpl:
getgetExchange