API Note
When the frame decoder returns a partial
frame, the same frame will be returned until its payload has been
fully read.
The caller is supposed to call readPayloadBytes() until
poll() returns a different frame. At this point there will be no
remaining payload bytes to read for
the previous frame.
The sequence of calls:
framesDecoder.submit(buffer);
while ((frame = framesDecoder.poll()) != null) {
if (frame instanceof PartialFrame partial) {
var nextPayloadBytes = framesDecoder.readPayloadBytes();
if (nextPayloadBytes == null || nextPayloadBytes.isEmpty()) {
// no more data is available at this moment
break;
}
// nextPayloadBytes are the next bytes for the payload
// of the partial frame
deliverBytes(partial, nextPayloadBytes);
} else ...
// got a full frame...
}
poll() will always return the same partial
frame until all its payload has been read.
| Modifier and Type | Field and Description |
|---|---|
| private final Supplier | |
| private final Logger | |
| pack-priv boolean | |
| private final BuffersReader. | |
| private final LongPredicate | |
| private final ReentrantLock | |
| pack-priv PartialFrame |
| Access | Constructor and Description |
|---|---|
| public | |
| public | FramesDecoder(String
a debug tag for logging dbgTag, LongPredicate isAllowed)A new |
| public | FramesDecoder(Supplier<String>
a debug tag for logging dbgTag, LongPredicate isAllowed)A new |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | |
| public boolean | |
| public void | |
| pack-priv String | |
| public boolean | Returns: true if EOF has been reached and all buffers have been readReturns true if EOF has been reached and all buffers have been read. |
| protected boolean | Returns: true if the frame is allowedthe frame type frameType)Can be overridden by subclasses to avoid parsing a frame fully if the frame is not allowed on this stream, or according to the stream state. |
| public static boolean | Returns: whether a frame of this type is allowed on a control stream.a frame type frameType)A predicate that returns true for all frames types allowed on the client->server control stream. |
| public static boolean | Returns: whether a frame of this type is allowed on a control stream.a frame type frameType)A predicate that returns true for all frames types allowed on the server->client control stream. |
| public static boolean | Returns: whether a frame of this type is allowed on a request/response stream.a frame type frameType)A predicate that returns true for all frames types allowed on a push promise stream. |
| public static boolean | Returns: whether a frame of this type is allowed on a request/response stream.a frame type frameType)A predicate that returns true for all frames types allowed on a request/response stream. |
| public Http3Frame | |
| public List | Returns: the next payload bytes for the current partial frame, ornull if no partial frameReturns the next payload bytes for the current partial frame,
or |
| public void |
| dbgTag | back to summary |
|---|---|
| private final Supplier<String> dbgTag | |
| debug | back to summary |
|---|---|
| private final Logger debug | |
| eof | back to summary |
|---|---|
| pack-priv boolean eof | |
| framesReader | back to summary |
|---|---|
| private final BuffersReader. | |
| isAllowed | back to summary |
|---|---|
| private final LongPredicate isAllowed | |
| lock | back to summary |
|---|---|
| private final ReentrantLock lock | |
| partialFrame | back to summary |
|---|---|
| pack-priv PartialFrame partialFrame | |
| FramesDecoder | back to summary |
|---|---|
| public FramesDecoder(String dbgTag) A new
| |
| FramesDecoder | back to summary |
|---|---|
| public FramesDecoder(String dbgTag, LongPredicate isAllowed) A new
| |
| FramesDecoder | back to summary |
|---|---|
| public FramesDecoder(Supplier<String> dbgTag, LongPredicate isAllowed) A new | |
| allAllowed | back to summary |
|---|---|
| private static boolean allAllowed(long frameType) | |
| clean | back to summary |
|---|---|
| public boolean clean() Returns true if all buffers have been read.
| |
| clear | back to summary |
|---|---|
| public void clear() Clears any unconsumed buffers. | |
| dbgTag | back to summary |
|---|---|
| pack-priv String dbgTag() | |
| eof | back to summary |
|---|---|
| public boolean eof() Returns true if EOF has been reached and all buffers have been read.
| |
| isAllowed | back to summary |
|---|---|
| protected boolean isAllowed(long frameType) Can be overridden by subclasses to avoid parsing a frame fully if the frame is not allowed on this stream, or according to the stream state. Implementation Specification This method delegates to the predicate given at construction time. If no predicate was given this method returns true.
| |
| isAllowedOnClientControlStream | back to summary |
|---|---|
| public static boolean isAllowedOnClientControlStream(long frameType) A predicate that returns true for all frames types allowed on the client->server control stream.
| |
| isAllowedOnControlStream | back to summary |
|---|---|
| public static boolean isAllowedOnControlStream(long frameType) A predicate that returns true for all frames types allowed on the server->client control stream.
| |
| isAllowedOnPromiseStream | back to summary |
|---|---|
| public static boolean isAllowedOnPromiseStream(long frameType) A predicate that returns true for all frames types allowed on a push promise stream.
| |
| isAllowedOnRequestStream | back to summary |
|---|---|
| public static boolean isAllowedOnRequestStream(long frameType) A predicate that returns true for all frames types allowed on a request/response stream.
| |
| poll | back to summary |
|---|---|
| public Http3Frame poll() Returns an
| |
| readPayloadBytes | back to summary |
|---|---|
| public List Returns the next payload bytes for the current partial frame,
or
| |
| submit | back to summary |
|---|---|
| public void submit(ByteBuffer buffer) Submit a new buffer to this frames decoder
| |