Module bus.http

Class Http2Reader

java.lang.Object
org.miaixz.bus.http.metric.http.Http2Reader
All Implemented Interfaces:
Closeable, AutoCloseable

public class Http2Reader extends Object implements Closeable
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

    Fields
    Modifier and Type
    Field
    Description
    final boolean
    True if this is a client endpoint.
    final org.miaixz.bus.http.metric.http.Http2Reader.ContinuationSource
    A source that reads continuation frames.
    final org.miaixz.bus.http.metric.http.Hpack.Reader
    The HPACK reader for decoding headers.
    final org.miaixz.bus.core.io.source.BufferSource
    The underlying source from which frames are read.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    nextFrame(boolean requireSettings, org.miaixz.bus.http.metric.http.Http2Reader.Handler handler)
    Reads the next frame from the source.
    void
    readConnectionPreface(org.miaixz.bus.http.metric.http.Http2Reader.Handler handler)
    Reads the connection preface, which is different for clients and servers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hpackReader

      public final org.miaixz.bus.http.metric.http.Hpack.Reader hpackReader
      The HPACK reader for decoding headers.
    • source

      public final org.miaixz.bus.core.io.source.BufferSource source
      The underlying source from which frames are read.
    • continuation

      public final org.miaixz.bus.http.metric.http.Http2Reader.ContinuationSource continuation
      A source that reads continuation frames.
    • client

      public final boolean client
      True 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

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException