Package org.apache.http.impl.nio.codecs
Class AbstractMessageParser<T extends org.apache.http.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 org.apache.http.HttpMessage>
extends Object
implements NHttpMessageParser<T>
Abstract
NHttpMessageParser that serves as a base for all message
parser implementations.- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMessageParser(SessionInputBuffer buffer, org.apache.http.message.LineParser lineParser, org.apache.http.config.MessageConstraints constraints) Creates an instance of AbstractMessageParser.AbstractMessageParser(SessionInputBuffer buffer, org.apache.http.message.LineParser lineParser, org.apache.http.params.HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TcreateMessage(org.apache.http.util.CharArrayBuffer buffer) CreatesHttpMessageinstance based on the content of the input buffer containing the first line of the incoming HTTP message.intfillBuffer(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.voidreset()Resets the parser.
-
Field Details
-
lineParser
protected final org.apache.http.message.LineParser lineParser
-
-
Constructor Details
-
AbstractMessageParser
@Deprecated public AbstractMessageParser(SessionInputBuffer buffer, org.apache.http.message.LineParser lineParser, org.apache.http.params.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, org.apache.http.message.LineParser lineParser, org.apache.http.config.MessageConstraints constraints) Creates an instance of AbstractMessageParser.- Parameters:
buffer- the session input buffer.lineParser- the line parser. IfnullBasicLineParser.INSTANCEwill be used.constraints- Message constraints. IfnullMessageConstraints.DEFAULTwill be used.- Since:
- 4.3
-
-
Method Details
-
reset
public void reset()Description copied from interface:NHttpMessageParserResets the parser. The parser will be ready to start parsing another HTTP message.- Specified by:
resetin interfaceNHttpMessageParser<T extends org.apache.http.HttpMessage>
-
fillBuffer
Description copied from interface:NHttpMessageParserFills the internal buffer of the parser with input data from the givenReadableByteChannel.- Specified by:
fillBufferin interfaceNHttpMessageParser<T extends org.apache.http.HttpMessage>- Parameters:
channel- the input channel- Returns:
- number of bytes read.
- Throws:
IOException- in case of an I/O error.
-
createMessage
protected abstract T createMessage(org.apache.http.util.CharArrayBuffer buffer) throws org.apache.http.HttpException, org.apache.http.ParseException CreatesHttpMessageinstance 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:
org.apache.http.HttpException- in case of HTTP protocol violationorg.apache.http.ParseException- in case of a parse error.
-
parse
Description copied from interface:NHttpMessageParserAttempts 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:
parsein interfaceNHttpMessageParser<T extends org.apache.http.HttpMessage>- Returns:
- HTTP message head, if available,
nullotherwise. - Throws:
IOException- in case of an I/O error.org.apache.http.HttpException- in case the HTTP message is malformed or violates the HTTP protocol.
-
AbstractMessageParser(SessionInputBuffer, LineParser, MessageConstraints)