public class Parser
extends java.lang.Object
The HTTP/2 protocol parser.
This parser makes use of the HeaderParser
and of
BodyParser
s to parse HTTP/2 frames.
Modifier and Type | Class and Description |
---|---|
static interface |
Parser.Listener |
private static class |
Parser.State |
Modifier and Type | Field and Description |
---|---|
private BodyParser[] |
bodyParsers |
private ByteBufferPool |
byteBufferPool |
private boolean |
continuation |
private HeaderParser |
headerParser |
private HpackDecoder |
hpackDecoder |
private Parser.Listener |
listener |
private static Logger |
LOG |
private int |
maxFrameLength |
private int |
maxSettingsKeys |
private Parser.State |
state |
private UnknownBodyParser |
unknownBodyParser |
Constructor and Description |
---|
Parser(ByteBufferPool byteBufferPool,
Parser.Listener listener,
int maxDynamicTableSize,
int maxHeaderSize) |
Modifier and Type | Method and Description |
---|---|
private boolean |
connectionFailure(java.nio.ByteBuffer buffer,
ErrorCode error,
java.lang.String reason) |
protected int |
getFrameType() |
int |
getMaxFrameLength() |
int |
getMaxSettingsKeys() |
protected boolean |
hasFlag(int bit) |
void |
init(java.util.function.UnaryOperator<Parser.Listener> wrapper) |
protected void |
notifyConnectionFailure(int error,
java.lang.String reason) |
void |
parse(java.nio.ByteBuffer buffer)
Parses the given
buffer bytes and emit events to a Parser.Listener . |
protected boolean |
parseBody(java.nio.ByteBuffer buffer) |
protected boolean |
parseHeader(java.nio.ByteBuffer buffer) |
private void |
reset() |
void |
setMaxFrameLength(int maxFrameLength) |
void |
setMaxSettingsKeys(int maxSettingsKeys) |
private static final Logger LOG
private final ByteBufferPool byteBufferPool
private final Parser.Listener listener
private final HeaderParser headerParser
private final HpackDecoder hpackDecoder
private final BodyParser[] bodyParsers
private UnknownBodyParser unknownBodyParser
private int maxFrameLength
private int maxSettingsKeys
private boolean continuation
private Parser.State state
public Parser(ByteBufferPool byteBufferPool, Parser.Listener listener, int maxDynamicTableSize, int maxHeaderSize)
public void init(java.util.function.UnaryOperator<Parser.Listener> wrapper)
private void reset()
public void parse(java.nio.ByteBuffer buffer)
Parses the given buffer
bytes and emit events to a Parser.Listener
.
When this method returns, the buffer may not be fully consumed, so invocations to this method should be wrapped in a loop:
while (buffer.hasRemaining()) parser.parse(buffer);
buffer
- the buffer to parseprotected boolean parseHeader(java.nio.ByteBuffer buffer)
protected boolean parseBody(java.nio.ByteBuffer buffer)
private boolean connectionFailure(java.nio.ByteBuffer buffer, ErrorCode error, java.lang.String reason)
protected int getFrameType()
protected boolean hasFlag(int bit)
public int getMaxFrameLength()
public void setMaxFrameLength(int maxFrameLength)
public int getMaxSettingsKeys()
public void setMaxSettingsKeys(int maxSettingsKeys)
protected void notifyConnectionFailure(int error, java.lang.String reason)