Package org.miaixz.bus.http.metric.http
Class Http2Stream
java.lang.Object
org.miaixz.bus.http.metric.http.Http2Stream
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose(Http2ErrorCode rstStatusCode, IOException errorException) Abnormally terminate this stream.voidcloseLater(Http2ErrorCode 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()org.miaixz.bus.core.io.sink.SinkgetSink()Returns a sink that can be used to write data to the peer.org.miaixz.bus.core.io.source.SourceReturns 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.org.miaixz.bus.core.io.timout.TimeoutRemoves and returns the stream's received response headers, blocking if necessary until headers have been received.trailers()Returns the trailers.voidwriteHeaders(List<Http2Header> responseHeaders, boolean outFinished, boolean flushHeaders) Sends a reply to an incoming stream.org.miaixz.bus.core.io.timout.Timeout
-
Method Details
-
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.
- 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'.- Throws:
IOException
-
trailers
Returns the trailers. It is only safe to call this once the source stream has been completely exhausted.- Throws:
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<Http2Header> responseHeaders, boolean outFinished, boolean flushHeaders) throws IOException Sends a reply to an incoming stream.- Parameters:
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.- Throws:
IOException
-
enqueueTrailers
-
readTimeout
public org.miaixz.bus.core.io.timout.Timeout readTimeout() -
writeTimeout
public org.miaixz.bus.core.io.timout.Timeout writeTimeout() -
getSource
public org.miaixz.bus.core.io.source.Source getSource()Returns a source that reads data from the peer. -
getSink
public org.miaixz.bus.core.io.sink.Sink getSink()Returns a sink that can be used to write data to the peer.- Throws:
IllegalStateException- if this stream was initiated by the peer and awriteHeaders(java.util.List<org.miaixz.bus.http.metric.http.Http2Header>, boolean, boolean)has not yet been sent.
-
close
Abnormally terminate this stream. This blocks until theRST_STREAMframe has been transmitted.- Throws:
IOException
-
closeLater
Abnormally terminate this stream. This enqueues aRST_STREAMframe and returns immediately.
-