Package org.microproxy.frames
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
public sealed interface Http2Frame
extends HttpFrame
permits Http2Frame.Data, Http2Frame.Headers, Http2Frame.Priority, Http2Frame.RstStream, Http2Frame.Settings, Http2Frame.PushPromise, Http2Frame.Ping, Http2Frame.GoAway, Http2Frame.WindowUpdate, Http2Frame.Unknown
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordDATA (section 6.1).static final recordGOAWAY (section 6.8).static final recordHEADERS (section 6.2), with its whole decoded header block.static final recordPING (section 6.7); its 8 opaque octets as a big-endian long.static final recordPRIORITY (section 6.3), deprecated by RFC 9113; the proxy ignores it and never sends one.static final recordPUSH_PROMISE (section 6.6).static final recordRST_STREAM (section 6.4).static final recordSETTINGS (section 6.5): the identifiers and values the frame carries, in order.static final recordA frame of an extension type (section 5.5), such as ALTSVC (10) or PRIORITY_UPDATE (16).static final recordWINDOW_UPDATE (section 6.9), for a stream or the connection (stream 0). -
Field Summary
FieldsModifier and TypeFieldDescriptionThe names of the error codes (RFC 9113 section 7), indexed by code.The names of the settings this API names, indexed by identifier (nullfor none).static final intSETTINGS_ENABLE_CONNECT_PROTOCOL (RFC 8441).static final intSETTINGS_ENABLE_PUSH.static final intSETTINGS_HEADER_TABLE_SIZE.static final intSETTINGS_INITIAL_WINDOW_SIZE.static final intSETTINGS_MAX_CONCURRENT_STREAMS.static final intSETTINGS_MAX_FRAME_SIZE.static final intSETTINGS_MAX_HEADER_LIST_SIZE.static final intThe type code of CONTINUATION, which interceptors never see (it is folded into HEADERS).static final intThe type code of DATA.static final intThe type code of GOAWAY.static final intThe type code of HEADERS.static final intThe type code of PING.static final intThe type code of PRIORITY.static final intThe type code of PUSH_PROMISE.static final intThe type code of RST_STREAM.static final intThe type code of SETTINGS.static final intThe type code of WINDOW_UPDATE. -
Method Summary
Modifier and TypeMethodDescriptionstatic Http2Frame.Datadata(int streamId, byte[] data, boolean endStream) A DATA frame to inject.static StringerrorName(long code) The name of an error code, or its hexadecimal value for an unknown one.static Http2Frame.HeadersA HEADERS frame to inject.default FrameProtocolprotocol()The protocol the frame belongs to.static intThe identifier of a setting named assettingName(int)names it (aSETTINGS_prefix is allowed), or written as a number (0x10,16).static StringsettingName(int id) The name of a setting without itsSETTINGS_prefix, or its hexadecimal identifier for an extension one.intstreamId()The stream the frame belongs to, or 0 for the connection.static Http2Frame.Unknownunknown(int type, int flags, int streamId, byte[] payload) A frame of an extension type to inject; peers ignore types they do not know.
-
Field Details
-
TYPE_DATA
static final int TYPE_DATAThe type code of DATA.- See Also:
-
TYPE_HEADERS
static final int TYPE_HEADERSThe type code of HEADERS.- See Also:
-
TYPE_PRIORITY
static final int TYPE_PRIORITYThe type code of PRIORITY.- See Also:
-
TYPE_RST_STREAM
static final int TYPE_RST_STREAMThe type code of RST_STREAM.- See Also:
-
TYPE_SETTINGS
static final int TYPE_SETTINGSThe type code of SETTINGS.- See Also:
-
TYPE_PUSH_PROMISE
static final int TYPE_PUSH_PROMISEThe type code of PUSH_PROMISE.- See Also:
-
TYPE_PING
static final int TYPE_PINGThe type code of PING.- See Also:
-
TYPE_GOAWAY
static final int TYPE_GOAWAYThe type code of GOAWAY.- See Also:
-
TYPE_WINDOW_UPDATE
static final int TYPE_WINDOW_UPDATEThe type code of WINDOW_UPDATE.- See Also:
-
TYPE_CONTINUATION
static final int TYPE_CONTINUATIONThe 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_SIZESETTINGS_HEADER_TABLE_SIZE.- See Also:
-
SETTINGS_ENABLE_PUSH
static final int SETTINGS_ENABLE_PUSHSETTINGS_ENABLE_PUSH.- See Also:
-
SETTINGS_MAX_CONCURRENT_STREAMS
static final int SETTINGS_MAX_CONCURRENT_STREAMSSETTINGS_MAX_CONCURRENT_STREAMS.- See Also:
-
SETTINGS_INITIAL_WINDOW_SIZE
static final int SETTINGS_INITIAL_WINDOW_SIZESETTINGS_INITIAL_WINDOW_SIZE.- See Also:
-
SETTINGS_MAX_FRAME_SIZE
static final int SETTINGS_MAX_FRAME_SIZESETTINGS_MAX_FRAME_SIZE.- See Also:
-
SETTINGS_MAX_HEADER_LIST_SIZE
static final int SETTINGS_MAX_HEADER_LIST_SIZESETTINGS_MAX_HEADER_LIST_SIZE.- See Also:
-
SETTINGS_ENABLE_CONNECT_PROTOCOL
static final int SETTINGS_ENABLE_CONNECT_PROTOCOLSETTINGS_ENABLE_CONNECT_PROTOCOL (RFC 8441).- See Also:
-
ERROR_NAMES
The names of the error codes (RFC 9113 section 7), indexed by code. -
SETTING_NAMES
The names of the settings this API names, indexed by identifier (nullfor none).
-
-
Method Details
-
streamId
int streamId()The stream the frame belongs to, or 0 for the connection.- Returns:
- the stream identifier
-
protocol
Description copied from interface:HttpFrameThe protocol the frame belongs to.- Specified by:
protocolin interfaceHttpFrame- Returns:
FrameProtocol.HTTP_2orFrameProtocol.HTTP_3
-
data
A DATA frame to inject.- Parameters:
streamId- the streamdata- the contentendStream- whether it ends the stream- Returns:
- the frame
-
headers
A HEADERS frame to inject.- Parameters:
streamId- the streamfields- the header block, pseudo-headers firstendStream- whether it ends the stream- Returns:
- the frame
-
unknown
A frame of an extension type to inject; peers ignore types they do not know.- Parameters:
type- the type code, 10 to 255flags- the flags, 0 to 255streamId- the stream, or 0 for the connectionpayload- the payload- Returns:
- the frame
-
errorName
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, or0x...
-
settingName
The name of a setting without itsSETTINGS_prefix, or its hexadecimal identifier for an extension one.- Parameters:
id- the setting identifier- Returns:
- a name such as
MAX_FRAME_SIZE, or0x...
-
settingId
The identifier of a setting named assettingName(int)names it (aSETTINGS_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
-