public interface Connection
Typically instances of this class are created, connected and exercised automatically by the HTTP client. Applications may use this class to monitor HTTP connections as members of a connection pool.
Do not confuse this class with the misnamed
HttpURLConnection, which isn't so much a
connection as a single request/response exchange.
There are tradeoffs when selecting which options to include when negotiating a secure connection to a remote host. Newer TLS options are quite useful:
Unfortunately, older HTTPS servers refuse to connect when such options are presented. Rather than avoiding these options entirely, this class allows a connection to be attempted with modern options and then retried without them should the attempt fail.
Each connection can carry a varying number of streams, depending on the underlying protocol
being used. HTTP/1.x connections can carry either zero or one streams. HTTP/2 connections can
carry any number of streams, dynamically configured with
A connection currently carrying zero streams is an idle stream. We keep it alive because reusing
an existing connection is typically faster than establishing a new one.
When a single logical call requires multiple streams due to redirects or authorization challenges, we prefer to use the same physical connection for all streams in the sequence. There are potential performance and behavior consequences to this preference. To support this feature, this class separates allocations from streams. An allocation is created by a call, used for one or more streams, and then released. An allocated connection won't be stolen by other calls while a redirect or authorization challenge is being handled.
When the maximum concurrent streams limit is reduced, some allocations will be rescinded. Attempting to create new streams on these allocations will fail.
Note that an allocation may be released before its stream is completed. This is intended to make bookkeeping easier for the caller: releasing the allocation as soon as the terminal stream has been found. But only complete the stream once its data stream has been exhausted.
|Modifier and Type||Method and Description|
Returns the TLS handshake used to establish this connection, or null if the connection is not HTTPS.
Returns the protocol negotiated by this connection, or
Returns the route used by this connection.
Returns the socket that this connection is using.
Copyright © 2019. All rights reserved.