public final class Http2Stream extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close(ErrorCode rstStatusCode,
IOException errorException)
Abnormally terminate this stream.
|
void |
closeLater(ErrorCode errorCode)
Abnormally terminate this stream.
|
void |
enqueueTrailers(Headers trailers) |
Http2Connection |
getConnection() |
ErrorCode |
getErrorCode()
Returns the reason why this stream was closed, or null if it closed normally or has not yet
been closed.
|
int |
getId() |
Sink |
getSink()
Returns a sink that can be used to write data to the peer.
|
Source |
getSource()
Returns a source that reads data from the peer.
|
boolean |
isLocallyInitiated()
Returns true if this stream was created by this peer.
|
boolean |
isOpen()
Returns true if this stream is open.
|
Timeout |
readTimeout() |
Headers |
takeHeaders()
Removes and returns the stream's received response headers, blocking if necessary until headers
have been received.
|
Headers |
trailers()
Returns the trailers.
|
void |
writeHeaders(List<Header> responseHeaders,
boolean outFinished,
boolean flushHeaders)
Sends a reply to an incoming stream.
|
Timeout |
writeTimeout() |
public int getId()
public boolean isOpen()
SYN_RESET frame abnormally terminates the stream.
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.
public boolean isLocallyInitiated()
public Http2Connection getConnection()
public Headers takeHeaders() throws IOException
IOExceptionpublic Headers trailers() throws IOException
IOExceptionpublic ErrorCode getErrorCode()
public void writeHeaders(List<Header> responseHeaders, boolean outFinished, boolean flushHeaders) throws IOException
outFinished - true to eagerly finish the output stream to send data to the remote peer.
Corresponds to FLAG_FIN.flushHeaders - true to force flush the response headers. This should be true unless the
response body exists and will be written immediately.IOExceptionpublic void enqueueTrailers(Headers trailers)
public Timeout readTimeout()
public Timeout writeTimeout()
public Source getSource()
public Sink getSink()
IllegalStateException - if this stream was initiated by the peer and a writeHeaders(java.util.List<com.lark.oapi.okhttp.internal.http2.Header>, boolean, boolean) has not yet been sent.public void close(ErrorCode rstStatusCode, @Nullable IOException errorException) throws IOException
RST_STREAM frame has been
transmitted.IOExceptionpublic void closeLater(ErrorCode errorCode)
RST_STREAM frame and returns
immediately.Copyright © 2025. All rights reserved.