类 Http2Stream
java.lang.Object
com.lark.oapi.okhttp.internal.http2.Http2Stream
A logical bidirectional stream.
-
方法概要
修饰符和类型方法说明voidclose(ErrorCode rstStatusCode, IOException errorException) Abnormally terminate this stream.voidcloseLater(ErrorCode errorCode) Abnormally terminate this stream.voidenqueueTrailers(Headers trailers) Returns the reason why this stream was closed, or null if it closed normally or has not yet been closed.intgetId()getSink()Returns a sink that can be used to write data to the peer.Returns a source that reads data from the peer.booleanReturns true if this stream was created by this peer.booleanisOpen()Returns true if this stream is open.Removes and returns the stream's received response headers, blocking if necessary until headers have been received.trailers()Returns the trailers.voidwriteHeaders(List<Header> responseHeaders, boolean outFinished, boolean flushHeaders) Sends a reply to an incoming stream.
-
方法详细资料
-
getId
public int getId() -
isOpen
public boolean isOpen()Returns true if this stream is open. A stream is open until either:- A
SYN_RESETframe abnormally terminates the stream. - Both input and output streams have transmitted all data and headers.
Note that the input stream may continue to yield data even after a stream reports itself as not open. This is because input data is buffered.
- A
-
isLocallyInitiated
public boolean isLocallyInitiated()Returns true if this stream was created by this peer. -
getConnection
-
takeHeaders
Removes and returns the stream's received response headers, blocking if necessary until headers have been received. If the returned list contains multiple blocks of headers the blocks will be delimited by 'null'.- 抛出:
IOException
-
trailers
Returns the trailers. It is only safe to call this once the source stream has been completely exhausted.- 抛出:
IOException
-
getErrorCode
Returns the reason why this stream was closed, or null if it closed normally or has not yet been closed. -
writeHeaders
public void writeHeaders(List<Header> responseHeaders, boolean outFinished, boolean flushHeaders) throws IOException Sends a reply to an incoming stream.- 参数:
outFinished- true to eagerly finish the output stream to send data to the remote peer. Corresponds toFLAG_FIN.flushHeaders- true to force flush the response headers. This should be true unless the response body exists and will be written immediately.- 抛出:
IOException
-
enqueueTrailers
-
readTimeout
-
writeTimeout
-
getSource
Returns a source that reads data from the peer. -
getSink
Returns a sink that can be used to write data to the peer.- 抛出:
IllegalStateException- if this stream was initiated by the peer and awriteHeaders(java.util.List<com.lark.oapi.okhttp.internal.http2.Header>, boolean, boolean)has not yet been sent.
-
close
Abnormally terminate this stream. This blocks until theRST_STREAMframe has been transmitted.- 抛出:
IOException
-
closeLater
Abnormally terminate this stream. This enqueues aRST_STREAMframe and returns immediately.
-