类 Http2Connection
java.lang.Object
com.lark.oapi.okhttp.internal.http2.Http2Connection
- 所有已实现的接口:
Closeable,AutoCloseable
A socket connection to a remote peer. A connection hosts streams which can send and receive
data.
Many methods in this API are synchronous: the call is completed before the method returns. This is typical for Java but atypical for HTTP/2. This is motivated by exception transparency: an IOException that was triggered by a certain caller can be caught and handled by that caller.
-
嵌套类概要
嵌套类修饰符和类型类说明static classstatic classListener of streams and settings initiated by the peer. -
方法概要
修饰符和类型方法说明voidclose()Closes this connection.voidflush()booleanisHealthy(long nowNs) intReturns a new locally-initiated stream.intReturns the number ofopen streamson this connection.pushStream(int associatedStreamId, List<Header> requestHeaders, boolean out) Returns a new server-initiated stream.voidsetSettings(Settings settings) Mergessettingsinto this peer's settings and sends them to the remote peer.voidDegrades this connection such that new streams can neither be created locally, nor accepted from the remote peer.voidstart()Sends any initial frames and starts reading frames from the remote peer.voidCallers of this method are not thread safe, and sometimes on application threads.
-
方法详细资料
-
openStreamCount
public int openStreamCount()Returns the number ofopen streamson this connection. -
maxConcurrentStreams
public int maxConcurrentStreams() -
pushStream
public Http2Stream pushStream(int associatedStreamId, List<Header> requestHeaders, boolean out) throws IOException Returns a new server-initiated stream.- 参数:
associatedStreamId- the stream that triggered the sender to create this stream.out- true to create an output stream that we can use to send data to the remote peer. Corresponds toFLAG_FIN.- 抛出:
IOException
-
newStream
Returns a new locally-initiated stream.- 参数:
out- true to create an output stream that we can use to send data to the remote peer. Corresponds toFLAG_FIN.- 抛出:
IOException
-
writeData
public void writeData(int streamId, boolean outFinished, Buffer buffer, long byteCount) throws IOException Callers of this method are not thread safe, and sometimes on application threads. Most often, this method will be called to send a buffer worth of data to the peer.Writes are subject to the write window of the stream and the connection. Until there is a window sufficient to send
byteCount, the caller will block. For example, a user ofHttpURLConnectionwho flushes more bytes to the output stream than the connection's write window will block.Zero
byteCountwrites are not subject to flow control and will not block. The only use case for zerobyteCountis closing a flushed output stream.- 抛出:
IOException
-
flush
- 抛出:
IOException
-
shutdown
Degrades this connection such that new streams can neither be created locally, nor accepted from the remote peer. Existing streams are not impacted. This is intended to permit an endpoint to gracefully stop accepting new requests without harming previously established streams.- 抛出:
IOException
-
close
public void close()Closes this connection. This cancels all open streams and unanswered pings. It closes the underlying input and output streams and shuts down internal executor services.- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Closeable
-
start
Sends any initial frames and starts reading frames from the remote peer. This should be called afterHttp2Connection.Builder.build()for all new connections.- 抛出:
IOException
-
setSettings
Mergessettingsinto this peer's settings and sends them to the remote peer.- 抛出:
IOException
-
isHealthy
public boolean isHealthy(long nowNs)
-