Class AbstractMessageParser<T extends HttpMessage>
java.lang.Object
org.apache.hc.core5.http.impl.nio.AbstractMessageParser<T>
- All Implemented Interfaces:
NHttpMessageParser<T>
- Direct Known Subclasses:
DefaultHttpRequestParser
,DefaultHttpResponseParser
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private final List
<CharArrayBuffer> private CharArrayBuffer
private final LineParser
private T
private final Http1Config
private AbstractMessageParser.State
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractMessageParser
(LineParser lineParser, Http1Config messageConstraints) Creates an instance of AbstractMessageParser. -
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.(package private) LineParser
parse
(SessionInputBuffer sessionBuffer, boolean endOfStream) Attempts to parse a complete message head from the content of the internal buffer.private void
private T
void
reset()
Resets the parser.
-
Field Details
-
state
-
message
-
lineBuf
-
headerBufs
-
emptyLineCount
private int emptyLineCount -
lineParser
-
messageConstraints
-
-
Constructor Details
-
AbstractMessageParser
Creates an instance of AbstractMessageParser.- Parameters:
lineParser
- the line parser. Ifnull
LazyLineParser.INSTANCE
will be used.messageConstraints
- Message constraints. Ifnull
Http1Config.DEFAULT
will be used.- Since:
- 4.3
-
-
Method Details
-
getLineParser
LineParser getLineParser() -
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>
-
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 violation
-
parseHeadLine
- Throws:
IOException
HttpException
-
parseHeader
- Throws:
IOException
-
parse
public T parse(SessionInputBuffer sessionBuffer, boolean endOfStream) throws IOException, HttpException 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>
- Parameters:
sessionBuffer
- session input buffer.endOfStream
- end of stream flag- 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.
-