public final class RealConnection extends Http2Connection.Listener implements Connection
Modifier and Type | Field and Description |
---|---|
int |
allocationLimit
The maximum number of concurrent streams that can be carried by this connection.
|
List<Reference<StreamAllocation>> |
allocations
Current streams carried by this connection.
|
long |
idleAtNanos
Nanotime timestamp when
allocations.size() reached zero. |
boolean |
noNewStreams
If true, no new streams can be created on this connection.
|
int |
successCount |
REFUSE_INCOMING_STREAMS
Constructor and Description |
---|
RealConnection(ConnectionPool connectionPool,
Route route) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
void |
connect(int connectTimeout,
int readTimeout,
int writeTimeout,
int pingIntervalMillis,
boolean connectionRetryEnabled,
Call call,
EventListener eventListener) |
Handshake |
handshake()
Returns the TLS handshake used to establish this connection, or null if the connection is not
HTTPS.
|
boolean |
isEligible(Address address,
Route route)
Returns true if this connection can carry a stream allocation to
address . |
boolean |
isHealthy(boolean doExtensiveChecks)
Returns true if this connection is ready to host new streams.
|
boolean |
isMultiplexed()
Returns true if this is an HTTP/2 connection.
|
HttpCodec |
newCodec(OkHttpClient client,
Interceptor.Chain chain,
StreamAllocation streamAllocation) |
RealWebSocket.Streams |
newWebSocketStreams(StreamAllocation streamAllocation) |
void |
onSettings(Http2Connection connection)
When settings are received, adjust the allocation limit.
|
void |
onStream(Http2Stream stream)
Refuse incoming streams.
|
Protocol |
protocol()
Returns the protocol negotiated by this connection, or
Protocol.HTTP_1_1 if no protocol
has been negotiated. |
Route |
route()
Returns the route used by this connection.
|
Socket |
socket()
Returns the socket that this connection is using.
|
boolean |
supportsUrl(HttpUrl url) |
static RealConnection |
testConnection(ConnectionPool connectionPool,
Route route,
Socket socket,
long idleAtNanos) |
String |
toString() |
public boolean noNewStreams
public int successCount
public int allocationLimit
allocations.size() < allocationLimit
then new streams can be created on this connection.public final List<Reference<StreamAllocation>> allocations
public long idleAtNanos
allocations.size()
reached zero.public RealConnection(ConnectionPool connectionPool, Route route)
public static RealConnection testConnection(ConnectionPool connectionPool, Route route, Socket socket, long idleAtNanos)
public void connect(int connectTimeout, int readTimeout, int writeTimeout, int pingIntervalMillis, boolean connectionRetryEnabled, Call call, EventListener eventListener)
public boolean isEligible(Address address, @Nullable Route route)
address
. If non-null
route
is the resolved route for a connection.public boolean supportsUrl(HttpUrl url)
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain, StreamAllocation streamAllocation) throws SocketException
SocketException
public RealWebSocket.Streams newWebSocketStreams(StreamAllocation streamAllocation)
public Route route()
Connection
route
in interface Connection
public void cancel()
public Socket socket()
Connection
socket
in interface Connection
public boolean isHealthy(boolean doExtensiveChecks)
public void onStream(Http2Stream stream) throws IOException
onStream
in class Http2Connection.Listener
IOException
public void onSettings(Http2Connection connection)
onSettings
in class Http2Connection.Listener
public Handshake handshake()
Connection
handshake
in interface Connection
public boolean isMultiplexed()
public Protocol protocol()
Connection
Protocol.HTTP_1_1
if no protocol
has been negotiated. This method returns Protocol.HTTP_1_1
even if the remote peer is
using Protocol.HTTP_1_0
.protocol
in interface Connection
Copyright © 2018. All rights reserved.