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

pack-priv final Class HttpResponseImpl<T>

extends Object
implements HttpResponse<T>, Provider
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.websocket.RawChannel.Provider, java.net.http.HttpResponse
Imports
java.io.IOException, java.net.URI, java.nio.ByteBuffer, java.util.Optional, java.util.concurrent.locks.ReentrantLock, java.util.function.Supplier, javax.net.ssl.SSLSession, java.net.http.HttpClient, .HttpHeaders, .HttpRequest, .HttpResponse, jdk.internal.net.http.websocket.RawChannel

The implementation class for HttpResponse

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
HttpResponseImpl.RawChannelProvider

An auxiliary class used for RawChannel creation when creating a WebSocket.

Field Summary

Modifier and TypeField and Description
pack-priv final T
private final String
pack-priv final HttpHeaders
pack-priv final HttpRequest
pack-priv final HttpResponse<T>
pack-priv final HttpResponseImpl.RawChannelProvider
pack-priv final int
pack-priv final SSLSession
pack-priv final URI
pack-priv final HttpClient.Version

Constructor Summary

AccessConstructor and Description
public
HttpResponseImpl(HttpRequest initialRequest, Response response, HttpResponse<T> previousResponse, T body, Exchange<T> exch)

Method Summary

Modifier and TypeMethod and Description
public T
body()

Implements java.net.http.HttpResponse.body.

Returns the body.

public void
closeRawChannel()

Implements jdk.internal.net.http.websocket.RawChannel.Provider.closeRawChannel.

Closes the RawChannel that may have been used for WebSocket protocol.

private static Optional<String>
public Optional<String>
connectionLabel()

Overrides default java.net.http.HttpResponse.connectionLabel.

Returns if present, a label identifying the connection on which the response was received.

public HttpHeaders
headers()

Implements java.net.http.HttpResponse.headers.

Returns the received response headers.

public Optional<HttpResponse<T>>
previousResponse()

Implements java.net.http.HttpResponse.previousResponse.

Returns an Optional containing the previous intermediate response if one was received.

public RawChannel

Returns:

a RawChannel that may be used for WebSocket protocol.
rawChannel
()

Implements jdk.internal.net.http.websocket.RawChannel.Provider.rawChannel.

Returns a RawChannel that may be used for WebSocket protocol.

public HttpRequest
request()

Implements java.net.http.HttpResponse.request.

Returns the HttpRequest corresponding to this response.

public Optional<SSLSession>
sslSession()

Implements java.net.http.HttpResponse.sslSession.

Returns an Optional containing the SSLSession in effect for this response.

public int
statusCode()

Implements java.net.http.HttpResponse.statusCode.

Returns the status code for this response.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public URI
uri()

Implements java.net.http.HttpResponse.uri.

Returns the URI that the response was received from.

public HttpClient.Version
version()

Implements java.net.http.HttpResponse.version.

Returns the HTTP protocol version that was used for this response.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bodyback to summary
pack-priv final T body
connectionLabelback to summary
private final String connectionLabel
headersback to summary
pack-priv final HttpHeaders headers
initialRequestback to summary
pack-priv final HttpRequest initialRequest
previousResponseback to summary
pack-priv final HttpResponse<T> previousResponse
rawChannelProviderback to summary
pack-priv final HttpResponseImpl.RawChannelProvider rawChannelProvider
responseCodeback to summary
pack-priv final int responseCode
sslSessionback to summary
pack-priv final SSLSession sslSession
uriback to summary
pack-priv final URI uri
versionback to summary
pack-priv final HttpClient.Version version

Constructor Detail

HttpResponseImplback to summary
public HttpResponseImpl(HttpRequest initialRequest, Response response, HttpResponse<T> previousResponse, T body, Exchange<T> exch)

Method Detail

bodyback to summary
public T body()

Implements java.net.http.HttpResponse.body.

Doc from java.net.http.HttpResponse.body.

Returns the body. Depending on the type of T, the returned body may represent the body after it was read (such as byte[], or String, or Path) or it may represent an object with which the body is read, such as an java.io.InputStream.

If this HttpResponse was returned from an invocation of previousResponse() then this method returns null

Annotations
@Override
closeRawChannelback to summary
public void closeRawChannel() throws IOException

Implements jdk.internal.net.http.websocket.RawChannel.Provider.closeRawChannel.

Closes the RawChannel that may have been used for WebSocket protocol.

API Note

This method should be called to close the connection if an exception occurs during the websocket handshake, in cases where rawChannel().close() would have been called. An unsuccessful handshake may prevent the creation of the RawChannel: if a RawChannel has already been created, this method wil close it. Otherwise, it will close the connection.

Annotations
@Override
Exceptions
IOException:
if an I/O exception occurs while closing the channel.
UnsupportedOperationException:
if getting a RawChannel over this connection is not supported.
connectionLabelback to summary
private static Optional<String> connectionLabel(Exchange<?> exchange)
connectionLabelback to summary
public Optional<String> connectionLabel()

Overrides default java.net.http.HttpResponse.connectionLabel.

Doc from java.net.http.HttpResponse.connectionLabel.

Returns if present, a label identifying the connection on which the response was received.

The format of the string is opaque, but the value is fixed and unique for any connection in the scope of the associated HttpClient instance.

Annotations
@Override
headersback to summary
public HttpHeaders headers()

Implements java.net.http.HttpResponse.headers.

Doc from java.net.http.HttpResponse.headers.

Returns the received response headers.

Annotations
@Override
previousResponseback to summary
public Optional<HttpResponse<T>> previousResponse()

Implements java.net.http.HttpResponse.previousResponse.

Doc from java.net.http.HttpResponse.previousResponse.

Returns an Optional containing the previous intermediate response if one was received. An intermediate response is one that is received as a result of redirection or authentication. If no previous response was received then an empty Optional is returned.

Annotations
@Override
rawChannelback to summary
public RawChannel rawChannel() throws IOException

Implements jdk.internal.net.http.websocket.RawChannel.Provider.rawChannel.

Returns a RawChannel that may be used for WebSocket protocol.

Implementation Note

This implementation does not support RawChannel over HTTP/2 connections.

Returns:RawChannel

a RawChannel that may be used for WebSocket protocol.

Annotations
@Override
Exceptions
IOException:
if an I/O exception occurs while retrieving the channel.
UnsupportedOperationException:
if getting a RawChannel over this connection is not supported.
requestback to summary
public HttpRequest request()

Implements java.net.http.HttpResponse.request.

Doc from java.net.http.HttpResponse.request.

Returns the HttpRequest corresponding to this response.

The returned HttpRequest may not be the initiating request provided when sending. For example, if the initiating request was redirected, then the request returned by this method will have the redirected URI, which will be different from the initiating request URI.

Annotations
@Override
sslSessionback to summary
public Optional<SSLSession> sslSession()

Implements java.net.http.HttpResponse.sslSession.

Doc from java.net.http.HttpResponse.sslSession.

Returns an Optional containing the SSLSession in effect for this response. Returns an empty Optional if this is not a HTTPS response.

Annotations
@Override
statusCodeback to summary
public int statusCode()

Implements java.net.http.HttpResponse.statusCode.

Doc from java.net.http.HttpResponse.statusCode.

Returns the status code for this response.

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
uriback to summary
public URI uri()

Implements java.net.http.HttpResponse.uri.

Doc from java.net.http.HttpResponse.uri.

Returns the URI that the response was received from. This may be different from the request URI if redirection occurred.

Annotations
@Override
versionback to summary
public HttpClient.Version version()

Implements java.net.http.HttpResponse.version.

Doc from java.net.http.HttpResponse.version.

Returns the HTTP protocol version that was used for this response.

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

private final Class HttpResponseImpl.RawChannelProvider

extends Object
implements Provider
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.websocket.RawChannel.Provider

An auxiliary class used for RawChannel creation when creating a WebSocket. This avoids keeping around references to connection/exchange in the regular HttpResponse case. Only those responses corresponding to an initial WebSocket request have a RawChannelProvider.

Field Summary

Modifier and TypeField and Description
private final HttpConnection
private final Exchange<?>
private RawChannel
private final ReentrantLock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
private static HttpConnection
connection(Response resp, Exchange<?> exch)

pack-priv static HttpResponseImpl.RawChannelProvider
create(Response resp, Exchange<?> exch)

private ExchangeImpl<?>
public RawChannel
private RawChannel
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
private final HttpConnection connection
exchangeback to summary
private final Exchange<?> exchange
rawchanback to summary
private RawChannel rawchan
stateLockback to summary
private final ReentrantLock stateLock

Constructor Detail

RawChannelProviderback to summary
pack-priv RawChannelProvider(HttpConnection conn, Exchange<?> exch)

Method Detail

closeRawChannelback to summary
public void closeRawChannel() throws IOException

Implements jdk.internal.net.http.websocket.RawChannel.Provider.closeRawChannel.

connectionback to summary
private static HttpConnection connection(Response resp, Exchange<?> exch)
createback to summary
pack-priv static HttpResponseImpl.RawChannelProvider create(Response resp, Exchange<?> exch)
exchangeImplback to summary
private ExchangeImpl<?> exchangeImpl()
rawChannelback to summary
public RawChannel rawChannel()

Implements jdk.internal.net.http.websocket.RawChannel.Provider.rawChannel.

Annotations
@Override
rawChannel0back to summary
private RawChannel rawChannel0()