Interface Http2Frame

All Superinterfaces:
HttpFrame
All Known Implementing Classes:
Http2Frame.Data, Http2Frame.GoAway, Http2Frame.Headers, Http2Frame.Ping, Http2Frame.Priority, Http2Frame.PushPromise, Http2Frame.RstStream, Http2Frame.Settings, Http2Frame.Unknown, Http2Frame.WindowUpdate

An HTTP/2 frame (RFC 9113 section 6) as a FrameInterceptor sees it: decoded, with header blocks as field lists (Field). CONTINUATION frames are folded into the HEADERS they continue, padding is gone, and HPACK is the proxy's business: a header block is decoded once, when it arrives, and encoded once, when it is sent, so edits never put the compression state of either side out of step.

Records are immutable apart from their byte arrays, which are not copied. Edit a frame with its with... methods and return the copy; build frames to inject with data(int, byte[], boolean), headers(int, java.util.List<org.microproxy.frames.Field>, boolean) and unknown(int, int, int, byte[]). Which edits the proxy accepts is described in FrameInterceptor.

  • Field Details

    • TYPE_DATA

      static final int TYPE_DATA
      The type code of DATA.
      See Also:
    • TYPE_HEADERS

      static final int TYPE_HEADERS
      The type code of HEADERS.
      See Also:
    • TYPE_PRIORITY

      static final int TYPE_PRIORITY
      The type code of PRIORITY.
      See Also:
    • TYPE_RST_STREAM

      static final int TYPE_RST_STREAM
      The type code of RST_STREAM.
      See Also:
    • TYPE_SETTINGS

      static final int TYPE_SETTINGS
      The type code of SETTINGS.
      See Also:
    • TYPE_PUSH_PROMISE

      static final int TYPE_PUSH_PROMISE
      The type code of PUSH_PROMISE.
      See Also:
    • TYPE_PING

      static final int TYPE_PING
      The type code of PING.
      See Also:
    • TYPE_GOAWAY

      static final int TYPE_GOAWAY
      The type code of GOAWAY.
      See Also:
    • TYPE_WINDOW_UPDATE

      static final int TYPE_WINDOW_UPDATE
      The type code of WINDOW_UPDATE.
      See Also:
    • TYPE_CONTINUATION

      static final int TYPE_CONTINUATION
      The type code of CONTINUATION, which interceptors never see (it is folded into HEADERS).
      See Also:
    • SETTINGS_HEADER_TABLE_SIZE

      static final int SETTINGS_HEADER_TABLE_SIZE
      SETTINGS_HEADER_TABLE_SIZE.
      See Also:
    • SETTINGS_ENABLE_PUSH

      static final int SETTINGS_ENABLE_PUSH
      SETTINGS_ENABLE_PUSH.
      See Also:
    • SETTINGS_MAX_CONCURRENT_STREAMS

      static final int SETTINGS_MAX_CONCURRENT_STREAMS
      SETTINGS_MAX_CONCURRENT_STREAMS.
      See Also:
    • SETTINGS_INITIAL_WINDOW_SIZE

      static final int SETTINGS_INITIAL_WINDOW_SIZE
      SETTINGS_INITIAL_WINDOW_SIZE.
      See Also:
    • SETTINGS_MAX_FRAME_SIZE

      static final int SETTINGS_MAX_FRAME_SIZE
      SETTINGS_MAX_FRAME_SIZE.
      See Also:
    • SETTINGS_MAX_HEADER_LIST_SIZE

      static final int SETTINGS_MAX_HEADER_LIST_SIZE
      SETTINGS_MAX_HEADER_LIST_SIZE.
      See Also:
    • SETTINGS_ENABLE_CONNECT_PROTOCOL

      static final int SETTINGS_ENABLE_CONNECT_PROTOCOL
      SETTINGS_ENABLE_CONNECT_PROTOCOL (RFC 8441).
      See Also:
    • ERROR_NAMES

      static final List<String> ERROR_NAMES
      The names of the error codes (RFC 9113 section 7), indexed by code.
    • SETTING_NAMES

      static final List<String> SETTING_NAMES
      The names of the settings this API names, indexed by identifier (null for none).
  • Method Details

    • streamId

      int streamId()
      The stream the frame belongs to, or 0 for the connection.
      Returns:
      the stream identifier
    • protocol

      default FrameProtocol protocol()
      Description copied from interface: HttpFrame
      The protocol the frame belongs to.
      Specified by:
      protocol in interface HttpFrame
      Returns:
      FrameProtocol.HTTP_2 or FrameProtocol.HTTP_3
    • data

      static Http2Frame.Data data(int streamId, byte[] data, boolean endStream)
      A DATA frame to inject.
      Parameters:
      streamId - the stream
      data - the content
      endStream - whether it ends the stream
      Returns:
      the frame
    • headers

      static Http2Frame.Headers headers(int streamId, List<Field> fields, boolean endStream)
      A HEADERS frame to inject.
      Parameters:
      streamId - the stream
      fields - the header block, pseudo-headers first
      endStream - whether it ends the stream
      Returns:
      the frame
    • unknown

      static Http2Frame.Unknown unknown(int type, int flags, int streamId, byte[] payload)
      A frame of an extension type to inject; peers ignore types they do not know.
      Parameters:
      type - the type code, 10 to 255
      flags - the flags, 0 to 255
      streamId - the stream, or 0 for the connection
      payload - the payload
      Returns:
      the frame
    • errorName

      static String errorName(long code)
      The name of an error code, or its hexadecimal value for an unknown one.
      Parameters:
      code - the unsigned 32-bit error code
      Returns:
      a name such as PROTOCOL_ERROR, or 0x...
    • settingName

      static String settingName(int id)
      The name of a setting without its SETTINGS_ prefix, or its hexadecimal identifier for an extension one.
      Parameters:
      id - the setting identifier
      Returns:
      a name such as MAX_FRAME_SIZE, or 0x...
    • settingId

      static int settingId(String name)
      The identifier of a setting named as settingName(int) names it (a SETTINGS_ prefix is allowed), or written as a number (0x10, 16).
      Parameters:
      name - the setting's name or number
      Returns:
      the identifier
      Throws:
      IllegalArgumentException - for a name that is neither