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

pack-priv Class Http1Response<T>

extends Object
Class Inheritance
Imports
java.io.EOFException, java.lang.System.Logger.Level, java.lang.invoke.MethodHandles, .VarHandle, java.net.http.HttpResponse.BodySubscriber, .HttpHeaders, .HttpResponse, java.net.ProtocolException, java.nio.ByteBuffer, java.util.concurrent.CompletableFuture, .Executor, java.util.concurrent.atomic.AtomicLong, java.util.function.Consumer, .Function, jdk.internal.net.http.ResponseContent.BodyParser, .ResponseContent.UnknownLengthBodyParser, jdk.internal.net.http.common.Log, .Logger, .MinimalFuture, .Utils

Handles a HTTP/1.1 response (headers + body). There can be more than one of these per Http exchange.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
private static class
pack-priv class
pack-priv abstract static class
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final Http1AsyncReceiver
private volatile ResponseContent.BodyParser
private final Http1Response<T>.BodyReader
private volatile boolean
private final HttpConnection
private volatile ResponseContent
pack-priv String
pack-priv final Logger
private volatile EOFException
private final Http1Exchange<T>
private boolean
private volatile boolean
private Http1HeaderParser
private HttpHeaders
private final Http1Response<T>.HeadersReader
pack-priv final long
private static final int
private volatile Http1Response.State
private final HttpRequestImpl
private Response
private int
pack-priv static final AtomicLong
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private Http1Response.State
pack-priv void
pack-priv synchronized void
private String
pack-priv synchronized boolean
pack-priv long
fixupContentLen(long clen)

Return known fixed content length or -1 if chunked, or -2 if no content-length information in which case, connection termination delimits the response body

public CompletableFuture<Void>
ignoreBody(Executor executor)

Reads the body, if it is present and less than 1024 bytes.

public void
private void
pack-priv void
public <U> CompletableFuture<U>
readBody(HttpResponse.BodySubscriber<U> p, boolean return2Cache, Executor executor)

public CompletableFuture<Response>
pack-priv Http1Response.Receiver<?>
pack-priv int
pack-priv HttpHeaders
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asyncReceiverback to summary
private final Http1AsyncReceiver asyncReceiver
bodyParserback to summary
private volatile ResponseContent.BodyParser bodyParser
bodyReaderback to summary
private final Http1Response<T>.BodyReader bodyReader
closeWhenFinishedback to summary
private volatile boolean closeWhenFinished
connectionback to summary
private final HttpConnection connection
contentback to summary
private volatile ResponseContent content
dbgTagback to summary
pack-priv String dbgTag
debugback to summary
pack-priv final Logger debug
eofback to summary
private volatile EOFException eof
exchangeback to summary
private final Http1Exchange<T> exchange
finishedback to summary
private boolean finished
firstTimeAroundback to summary
private volatile boolean firstTimeAround
hdback to summary
private Http1HeaderParser hd
headersback to summary
private HttpHeaders headers
headersReaderback to summary
private final Http1Response<T>.HeadersReader headersReader
idback to summary
pack-priv final long id
MAX_IGNOREback to summary
private static final int MAX_IGNORE
readProgressback to summary
private volatile Http1Response.State readProgress
requestback to summary
private final HttpRequestImpl request
responseback to summary
private Response response
responseCodeback to summary
private int responseCode
responseCountback to summary
pack-priv static final AtomicLong responseCount
return2Cacheback to summary
private boolean return2Cache

Constructor Detail

Http1Responseback to summary
pack-priv Http1Response(HttpConnection conn, Http1Exchange<T> exchange, Http1AsyncReceiver asyncReceiver)

Method Detail

advanceback to summary
private Http1Response.State advance(Http1Response.State previous)
closeWhenFinishedback to summary
pack-priv void closeWhenFinished()
completedback to summary
pack-priv synchronized void completed()
dbgStringback to summary
private String dbgString()
finishedback to summary
pack-priv synchronized boolean finished()
fixupContentLenback to summary
pack-priv long fixupContentLen(long clen)

Return known fixed content length or -1 if chunked, or -2 if no content-length information in which case, connection termination delimits the response body

ignoreBodyback to summary
public CompletableFuture<Void> ignoreBody(Executor executor)

Reads the body, if it is present and less than 1024 bytes. Otherwise, just the connection is closed.

nullBodyback to summary
public void nullBody(HttpResponse<T> resp, Throwable t)
onFinishedback to summary
private void onFinished()
onReadErrorback to summary
pack-priv void onReadError(Throwable t)
readBodyback to summary
public <U> CompletableFuture<U> readBody(HttpResponse.BodySubscriber<U> p, boolean return2Cache, Executor executor)
readHeadersAsyncback to summary
public CompletableFuture<Response> readHeadersAsync(Executor executor)
receiverback to summary
pack-priv Http1Response.Receiver<?> receiver(Http1Response.State state)
responseCodeback to summary
pack-priv int responseCode()
responseHeadersback to summary
pack-priv HttpHeaders responseHeaders()
jdk.internal.net.http back to summary

pack-priv final Class Http1Response.BodyReader

extends Http1Response.Receiver<ResponseContent.BodyParser>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile CompletableFuture<Http1Response.State>
pack-priv final Consumer<Http1Response.State>
pack-priv volatile ResponseContent.BodyParser
pack-priv volatile AbstractSubscription

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final void
close(Throwable error)

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Called to make sure resources are released when the Http1AsyncReceiver is stopped.

pack-priv CompletableFuture<Http1Response.State>
pack-priv final void
pack-priv final void
onComplete(Throwable closedExceptionally)

public final void
public void
pack-priv void
pack-priv final void
public AbstractSubscription
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public final boolean
Inherited from jdk.internal.net.http.Http1Response.Receiver:
accept

Field Detail

cfback to summary
pack-priv volatile CompletableFuture<Http1Response.State> cf
onCompleteback to summary
pack-priv final Consumer<Http1Response.State> onComplete
parserback to summary
pack-priv volatile ResponseContent.BodyParser parser
subscriptionback to summary
pack-priv volatile AbstractSubscription subscription

Constructor Detail

BodyReaderback to summary
pack-priv BodyReader(Consumer<Http1Response.State> onComplete)

Method Detail

closeback to summary
public final void close(Throwable error)

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Called to make sure resources are released when the Http1AsyncReceiver is stopped.

Annotations
@Override
completionback to summary
pack-priv CompletableFuture<Http1Response.State> completion()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.completion.

Annotations
@Override
handleback to summary
pack-priv final void handle(ByteBuffer b, ResponseContent.BodyParser parser, CompletableFuture<Http1Response.State> cf)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.handle.

Annotations
@Override
onCompleteback to summary
pack-priv final void onComplete(Throwable closedExceptionally)
onReadErrorback to summary
public final void onReadError(Throwable t)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.onReadError.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Called when an exception is raised.

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(AbstractSubscription s)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.onSubscribe.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Must be called before any other method on the delegate. The subscription can be either used directly by the delegate to request more data (e.g. if the delegate is a header parser), or can be forwarded to a downstream subscriber (if the delegate is a body parser that wraps a response BodySubscriber). In all cases, it is the responsibility of the delegate to ensure that request(n) and demand.tryDecrement() are called appropriately. No data will be sent to tryAsyncReceive unless the subscription has some demand.

Annotations
@Override
resetback to summary
pack-priv void reset()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.reset.

Annotations
@Override
startback to summary
pack-priv final void start(ResponseContent.BodyParser parser)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.start.

Annotations
@Override
subscriptionback to summary
public AbstractSubscription subscription()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.subscription.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Returns the subscription that was passed to onSubscribe

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
tryAsyncReceiveback to summary
public final boolean tryAsyncReceive(ByteBuffer b)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.tryAsyncReceive.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Receives and handles a byte buffer reference.

Annotations
@Override
jdk.internal.net.http back to summary

private final Class Http1Response.ClientRefCountTracker

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final HttpClientImpl
pack-priv final Logger
pack-priv volatile byte
private static final VarHandle

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clientback to summary
pack-priv final HttpClientImpl client
debugback to summary
pack-priv final Logger debug
stateback to summary
pack-priv volatile byte state
STATEback to summary
private static final VarHandle STATE

Constructor Detail

ClientRefCountTrackerback to summary
pack-priv ClientRefCountTracker(HttpClientImpl client, Logger logger)

Method Detail

acquireback to summary
public boolean acquire()
tryReleaseback to summary
public void tryRelease()
jdk.internal.net.http back to summary

pack-priv final Class Http1Response.HeadersReader

extends Http1Response.Receiver<Http1HeaderParser>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile CompletableFuture<Http1Response.State>
pack-priv volatile long
pack-priv final Consumer<Http1Response.State>
pack-priv volatile Http1HeaderParser
pack-priv volatile AbstractSubscription

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close(Throwable error)

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Called to make sure resources are released when the Http1AsyncReceiver is stopped.

pack-priv CompletableFuture<Http1Response.State>
pack-priv final void
public final void
public void
pack-priv void
pack-priv final void
public AbstractSubscription
public final boolean
Inherited from jdk.internal.net.http.Http1Response.Receiver:
accept

Field Detail

cfback to summary
pack-priv volatile CompletableFuture<Http1Response.State> cf
countback to summary
pack-priv volatile long count
onCompleteback to summary
pack-priv final Consumer<Http1Response.State> onComplete
parserback to summary
pack-priv volatile Http1HeaderParser parser
subscriptionback to summary
pack-priv volatile AbstractSubscription subscription

Constructor Detail

HeadersReaderback to summary
pack-priv HeadersReader(Consumer<Http1Response.State> onComplete)

Method Detail

closeback to summary
public void close(Throwable error)

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.close.

Called to make sure resources are released when the Http1AsyncReceiver is stopped.

Annotations
@Override
completionback to summary
pack-priv CompletableFuture<Http1Response.State> completion()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.completion.

Annotations
@Override
handleback to summary
pack-priv final void handle(ByteBuffer b, Http1HeaderParser parser, CompletableFuture<Http1Response.State> cf)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.handle.

Annotations
@Override
onReadErrorback to summary
public final void onReadError(Throwable t)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.onReadError.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Called when an exception is raised.

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(AbstractSubscription s)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.onSubscribe.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Must be called before any other method on the delegate. The subscription can be either used directly by the delegate to request more data (e.g. if the delegate is a header parser), or can be forwarded to a downstream subscriber (if the delegate is a body parser that wraps a response BodySubscriber). In all cases, it is the responsibility of the delegate to ensure that request(n) and demand.tryDecrement() are called appropriately. No data will be sent to tryAsyncReceive unless the subscription has some demand.

Annotations
@Override
resetback to summary
pack-priv void reset()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.reset.

Annotations
@Override
startback to summary
pack-priv final void start(Http1HeaderParser hp)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.start.

Annotations
@Override
subscriptionback to summary
public AbstractSubscription subscription()

Implements abstract jdk.internal.net.http.Http1Response.Receiver.subscription.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Returns the subscription that was passed to onSubscribe

Annotations
@Override
tryAsyncReceiveback to summary
public final boolean tryAsyncReceive(ByteBuffer ref)

Implements abstract jdk.internal.net.http.Http1Response.Receiver.tryAsyncReceive.

Implements jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Receives and handles a byte buffer reference.

Annotations
@Override
jdk.internal.net.http back to summary

pack-priv abstract Class Http1Response.Receiver<T>

extends Object
implements Http1AsyncDelegate
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate
Known Direct Subclasses
jdk.internal.net.http.Http1Response.HeadersReader, jdk.internal.net.http.Http1Response.BodyReader

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
pack-priv abstract CompletableFuture<Http1Response.State>
pack-priv abstract void
public abstract void
public abstract void
onSubscribe(AbstractSubscription s)

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Must be called before any other method on the delegate.

pack-priv abstract void
pack-priv abstract void
start(T parser)

public abstract AbstractSubscription
subscription()

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Returns the subscription that was passed to onSubscribe

public abstract boolean
tryAsyncReceive(ByteBuffer buffer)

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Receives and handles a byte buffer reference.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Receiverback to summary
pack-priv Receiver()

Method Detail

acceptback to summary
pack-priv final boolean accept(ByteBuffer buf, T parser, CompletableFuture<Http1Response.State> cf)
completionback to summary
pack-priv abstract CompletableFuture<Http1Response.State> completion()
handleback to summary
pack-priv abstract void handle(ByteBuffer buf, T parser, CompletableFuture<Http1Response.State> cf)
onReadErrorback to summary
public abstract void onReadError(Throwable t)

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onReadError.

Called when an exception is raised.

onSubscribeback to summary
public abstract void onSubscribe(AbstractSubscription s)

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.onSubscribe.

Must be called before any other method on the delegate. The subscription can be either used directly by the delegate to request more data (e.g. if the delegate is a header parser), or can be forwarded to a downstream subscriber (if the delegate is a body parser that wraps a response BodySubscriber). In all cases, it is the responsibility of the delegate to ensure that request(n) and demand.tryDecrement() are called appropriately. No data will be sent to tryAsyncReceive unless the subscription has some demand.

resetback to summary
pack-priv abstract void reset()
startback to summary
pack-priv abstract void start(T parser)
subscriptionback to summary
public abstract AbstractSubscription subscription()

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.subscription.

Returns the subscription that was passed to onSubscribe

tryAsyncReceiveback to summary
public abstract boolean tryAsyncReceive(ByteBuffer buffer)

Redeclares jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Doc from jdk.internal.net.http.Http1AsyncReceiver.Http1AsyncDelegate.tryAsyncReceive.

Receives and handles a byte buffer reference.

jdk.internal.net.http back to summary

pack-priv final Enum Http1Response.State

extends Enum<Http1Response.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Http1Response.State
public static final Http1Response.State
public static final Http1Response.State
public static final Http1Response.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Http1Response.State
public static Http1Response.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DONEback to summary
public static final Http1Response.State DONE
INITIALback to summary
public static final Http1Response.State INITIAL
READING_BODYback to summary
public static final Http1Response.State READING_BODY
READING_HEADERSback to summary
public static final Http1Response.State READING_HEADERS

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static Http1Response.State valueOf(String name)
valuesback to summary
public static Http1Response.State[] values()