public abstract class AbstractMessageParser<T extends HttpMessage> extends java.lang.Object implements NHttpMessageParser<T>
NHttpMessageParser that serves as a base for all message
parser implementations.| Modifier and Type | Field and Description |
|---|---|
private static int |
COMPLETED |
private MessageConstraints |
constraints |
private boolean |
endOfStream |
private java.util.List<CharArrayBuffer> |
headerBufs |
private CharArrayBuffer |
lineBuf |
protected LineParser |
lineParser |
private T |
message |
private static int |
READ_HEAD_LINE |
private static int |
READ_HEADERS |
private SessionInputBuffer |
sessionBuffer |
private int |
state |
| Constructor and Description |
|---|
AbstractMessageParser(SessionInputBuffer buffer,
LineParser lineParser,
HttpParams params)
Deprecated.
|
AbstractMessageParser(SessionInputBuffer buffer,
LineParser lineParser,
MessageConstraints constraints)
Creates an instance of AbstractMessageParser.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
createMessage(CharArrayBuffer buffer)
Creates
HttpMessage instance based on the content of the input
buffer containing the first line of the incoming HTTP message. |
int |
fillBuffer(java.nio.channels.ReadableByteChannel channel)
Fills the internal buffer of the parser with input data from the
given
ReadableByteChannel. |
T |
parse()
Attempts to parse a complete message head from the content of the
internal buffer.
|
private void |
parseHeader() |
private void |
parseHeadLine() |
void |
reset()
Resets the parser.
|
private final SessionInputBuffer sessionBuffer
private static final int READ_HEAD_LINE
private static final int READ_HEADERS
private static final int COMPLETED
private int state
private boolean endOfStream
private T extends HttpMessage message
private CharArrayBuffer lineBuf
private final java.util.List<CharArrayBuffer> headerBufs
protected final LineParser lineParser
private final MessageConstraints constraints
@Deprecated public AbstractMessageParser(SessionInputBuffer buffer, LineParser lineParser, HttpParams params)
AbstractMessageParser(SessionInputBuffer, LineParser,
MessageConstraints)buffer - the session input buffer.lineParser - the line parser.params - HTTP parameters.public AbstractMessageParser(SessionInputBuffer buffer, LineParser lineParser, MessageConstraints constraints)
buffer - the session input buffer.lineParser - the line parser. If null BasicLineParser.INSTANCE
will be used.constraints - Message constraints. If null
MessageConstraints.DEFAULT will be used.public void reset()
NHttpMessageParserreset in interface NHttpMessageParser<T extends HttpMessage>public int fillBuffer(java.nio.channels.ReadableByteChannel channel)
throws java.io.IOException
NHttpMessageParserReadableByteChannel.fillBuffer in interface NHttpMessageParser<T extends HttpMessage>channel - the input channeljava.io.IOException - in case of an I/O error.protected abstract T createMessage(CharArrayBuffer buffer) throws HttpException, ParseException
HttpMessage instance based on the content of the input
buffer containing the first line of the incoming HTTP message.buffer - the line buffer.HttpException - in case of HTTP protocol violationParseException - in case of a parse error.private void parseHeadLine()
throws HttpException,
ParseException
HttpExceptionParseExceptionprivate void parseHeader()
throws java.io.IOException
java.io.IOExceptionpublic T parse() throws java.io.IOException, HttpException
NHttpMessageParsernull.parse in interface NHttpMessageParser<T extends HttpMessage>null otherwise.java.io.IOException - in case of an I/O error.HttpException - in case the HTTP message is malformed or
violates the HTTP protocol.