Package dev.relism.flash.http2.frame
Class Padding
java.lang.Object
dev.relism.flash.http2.frame.Padding
RFC 9113 §6.1 (DATA) / §6.2 (HEADERS) padding. When
FrameFlags.PADDED is set, a
frame's payload is laid out as: 1 pad-length byte, then the actual data (or header-block
fragment), then that many padding bytes (RFC 9113 gives no meaning to the padding bytes
themselves — they exist only to obscure payload size from network observers).
Padding is not optional to support: any client may send it on DATA or HEADERS regardless of whether the server ever sends padded frames itself.
Flow control (forward note, not implemented here)
RFC 9113 §6.9.1: padding bytes count against the DATA flow-control window even though they carry no data — the whole frame payload (pad-length byte + data + padding) is what a #dataLength(long)}. This class only locates the data range within the payload; it performs no flow-control accounting itself.-
Method Summary
Modifier and TypeMethodDescriptionstatic intdataLength(long unpadded) Extracts the data length from a value returned byunpad(byte[], int, int, boolean).static intdataOffset(long unpadded) Extracts the data offset from a value returned byunpad(byte[], int, int, boolean).static longunpad(byte[] buf, int payloadOffset, int payloadLength, boolean padded) Locates the actual data range within a payload that may or may not be padded.
-
Method Details
-
unpad
public static long unpad(byte[] buf, int payloadOffset, int payloadLength, boolean padded) Locates the actual data range within a payload that may or may not be padded. Whenpaddedisfalse, returns the whole payload unchanged (zero-cost — no padding byte to read, no arithmetic beyond the pack). Whentrue, reads the pad-length byte atbuf[payloadOffset], validates it, and returns the data range that follows it.- Returns:
Pairs.pack(dataOffset, dataLength)— unpack withPairs.hi(long)/Pairs.lo(long)- Throws:
Http2Exception- (PROTOCOL_ERROR) ifpaddedis set butpayloadLength == 0(no room for the pad-length byte itself), or if the claimed pad length is greater than or equal to the whole payload length (RFC 9113 §6.1: "If the length of the padding is the length of the frame payload or greater, the recipient MUST treat this as a connection error")
-
dataOffset
public static int dataOffset(long unpadded) Extracts the data offset from a value returned byunpad(byte[], int, int, boolean). -
dataLength
public static int dataLength(long unpadded) Extracts the data length from a value returned byunpad(byte[], int, int, boolean).
-