java.lang.Object
org.miaixz.bus.http.metric.http.Http2Reader
- All Implemented Interfaces:
Closeable,AutoCloseable
Reads HTTP/2 transport frames. This implementation assumes we haven't sent a SETTINGS frame to the peer that
increases the frame size. Therefore, we expect all frames to have a maximum length of
Http2.INITIAL_MAX_FRAME_SIZE.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanTrue if this is a client endpoint.final org.miaixz.bus.http.metric.http.Http2Reader.ContinuationSourceA source that reads continuation frames.final org.miaixz.bus.http.metric.http.Hpack.ReaderThe HPACK reader for decoding headers.final org.miaixz.bus.core.io.source.BufferSourceThe underlying source from which frames are read. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleannextFrame(boolean requireSettings, org.miaixz.bus.http.metric.http.Http2Reader.Handler handler) Reads the next frame from the source.voidreadConnectionPreface(org.miaixz.bus.http.metric.http.Http2Reader.Handler handler) Reads the connection preface, which is different for clients and servers.
-
Field Details
-
hpackReader
public final org.miaixz.bus.http.metric.http.Hpack.Reader hpackReaderThe HPACK reader for decoding headers. -
source
public final org.miaixz.bus.core.io.source.BufferSource sourceThe underlying source from which frames are read. -
continuation
public final org.miaixz.bus.http.metric.http.Http2Reader.ContinuationSource continuationA source that reads continuation frames. -
client
public final boolean clientTrue if this is a client endpoint.
-
-
Method Details
-
readConnectionPreface
public void readConnectionPreface(org.miaixz.bus.http.metric.http.Http2Reader.Handler handler) throws IOException Reads the connection preface, which is different for clients and servers.- Parameters:
handler- The handler for frame events.- Throws:
IOException- if an I/O error occurs or the preface is incorrect.
-
nextFrame
public boolean nextFrame(boolean requireSettings, org.miaixz.bus.http.metric.http.Http2Reader.Handler handler) throws IOException Reads the next frame from the source. This is a blocking call.- Parameters:
requireSettings- True if the next frame must be a SETTINGS frame.handler- The handler for frame events.- Returns:
- True if a frame was read, false if the stream is exhausted.
- Throws:
IOException- if an I/O error occurs.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-