@NotThreadSafe public abstract class AbstractMessageParser<T extends HttpMessage> extends Object implements NHttpMessageParser<T>
NHttpMessageParser
that serves as a base for all message
parser implementations.
The following parameters can be used to customize the behavior of this class:
Modifier and Type | Field and Description |
---|---|
protected LineParser |
lineParser |
Constructor and Description |
---|
AbstractMessageParser(SessionInputBuffer buffer,
LineParser parser,
HttpParams params)
Creates an instance of this class.
|
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(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.
|
void |
reset()
Resets the parser.
|
protected final LineParser lineParser
public AbstractMessageParser(SessionInputBuffer buffer, LineParser parser, HttpParams params)
buffer
- the session input buffer.parser
- the line parser.params
- HTTP parameters.public void reset()
NHttpMessageParser
reset
in interface NHttpMessageParser<T extends HttpMessage>
public int fillBuffer(ReadableByteChannel channel) throws IOException
NHttpMessageParser
ReadableByteChannel
.fillBuffer
in interface NHttpMessageParser<T extends HttpMessage>
channel
- the input channelIOException
- 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.public T parse() throws IOException, HttpException
NHttpMessageParser
null
.parse
in interface NHttpMessageParser<T extends HttpMessage>
null
otherwise.IOException
- in case of an I/O error.HttpException
- in case the HTTP message is malformed or
violates the HTTP protocol.Copyright © 2005-2015 The Apache Software Foundation. All Rights Reserved.