Package org.apache.http.impl.nio.codecs
Class AbstractMessageParser<T extends HttpMessage>
java.lang.Object
org.apache.http.impl.nio.codecs.AbstractMessageParser<T>
- All Implemented Interfaces:
NHttpMessageParser<T>
- Direct Known Subclasses:
DefaultHttpRequestParser
,DefaultHttpResponseParser
,HttpRequestParser
,HttpResponseParser
public abstract class AbstractMessageParser<T extends HttpMessage>
extends Object
implements NHttpMessageParser<T>
Abstract
NHttpMessageParser
that serves as a base for all message
parser implementations.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final MessageConstraints
private boolean
private final List
<CharArrayBuffer> private CharArrayBuffer
protected final LineParser
private T
private static final int
private static final int
private final SessionInputBuffer
private int
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractMessageParser
(SessionInputBuffer buffer, LineParser lineParser, MessageConstraints constraints) Creates an instance of AbstractMessageParser.AbstractMessageParser
(SessionInputBuffer buffer, LineParser lineParser, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
createMessage
(CharArrayBuffer buffer) CreatesHttpMessage
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 givenReadableByteChannel
.parse()
Attempts to parse a complete message head from the content of the internal buffer.private void
private void
void
reset()
Resets the parser.
-
Field Details
-
sessionBuffer
-
READ_HEAD_LINE
private static final int READ_HEAD_LINE- See Also:
-
READ_HEADERS
private static final int READ_HEADERS- See Also:
-
COMPLETED
private static final int COMPLETED- See Also:
-
state
private int state -
endOfStream
private boolean endOfStream -
message
-
lineBuf
-
headerBufs
-
lineParser
-
constraints
-
-
Constructor Details
-
AbstractMessageParser
@Deprecated public AbstractMessageParser(SessionInputBuffer buffer, LineParser lineParser, HttpParams params) Deprecated.Creates an instance of this class.- Parameters:
buffer
- the session input buffer.lineParser
- the line parser.params
- HTTP parameters.
-
AbstractMessageParser
public AbstractMessageParser(SessionInputBuffer buffer, LineParser lineParser, MessageConstraints constraints) Creates an instance of AbstractMessageParser.- Parameters:
buffer
- the session input buffer.lineParser
- the line parser. Ifnull
BasicLineParser.INSTANCE
will be used.constraints
- Message constraints. Ifnull
MessageConstraints.DEFAULT
will be used.- Since:
- 4.3
-
-
Method Details
-
reset
public void reset()Description copied from interface:NHttpMessageParser
Resets the parser. The parser will be ready to start parsing another HTTP message.- Specified by:
reset
in interfaceNHttpMessageParser<T extends HttpMessage>
-
fillBuffer
Description copied from interface:NHttpMessageParser
Fills the internal buffer of the parser with input data from the givenReadableByteChannel
.- Specified by:
fillBuffer
in interfaceNHttpMessageParser<T extends HttpMessage>
- Parameters:
channel
- the input channel- Returns:
- number of bytes read.
- Throws:
IOException
- in case of an I/O error.
-
createMessage
CreatesHttpMessage
instance based on the content of the input buffer containing the first line of the incoming HTTP message.- Parameters:
buffer
- the line buffer.- Returns:
- HTTP message.
- Throws:
HttpException
- in case of HTTP protocol violationParseException
- in case of a parse error.
-
parseHeadLine
- Throws:
HttpException
ParseException
-
parseHeader
- Throws:
IOException
-
parse
Description copied from interface:NHttpMessageParser
Attempts to parse a complete message head from the content of the internal buffer. If the message in the input buffer is incomplete this method will returnnull
.- Specified by:
parse
in interfaceNHttpMessageParser<T extends HttpMessage>
- Returns:
- HTTP message head, if available,
null
otherwise. - Throws:
IOException
- in case of an I/O error.HttpException
- in case the HTTP message is malformed or violates the HTTP protocol.
-
AbstractMessageParser(SessionInputBuffer, LineParser, MessageConstraints)