Class AbstractMessageParser<T extends HttpMessage>
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractMessageParser<T>
-
- Type Parameters:
T- The type ofHttpMessage.
- All Implemented Interfaces:
NHttpMessageParser<T>
- Direct Known Subclasses:
DefaultHttpRequestParser,DefaultHttpResponseParser
public abstract class AbstractMessageParser<T extends HttpMessage> extends java.lang.Object implements NHttpMessageParser<T>
AbstractNHttpMessageParserthat serves as a base for all message parser implementations.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractMessageParser.State
-
Field Summary
Fields Modifier and Type Field Description private intemptyLineCountprivate java.util.List<CharArrayBuffer>headerBufsprivate Http1Confighttp1Configprivate CharArrayBufferlineBufprivate LineParserlineParserprivate Tmessageprivate AbstractMessageParser.Statestate
-
Constructor Summary
Constructors Constructor Description AbstractMessageParser(Http1Config http1Config, LineParser lineParser)Constructs a new instance for a subclass.AbstractMessageParser(LineParser lineParser, Http1Config messageConstraints)Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcreateMessage(CharArrayBuffer buffer)CreatesHttpMessageinstance based on the content of the input buffer containing the first line of the incoming HTTP message.(package private) LineParsergetLineParser()Tparse(SessionInputBuffer sessionBuffer, boolean endOfStream)Attempts to parse a complete message head from the content of the internal buffer.private voidparseHeader()private TparseHeadLine()voidreset()Resets the parser.
-
-
-
Field Detail
-
http1Config
private final Http1Config http1Config
-
lineParser
private final LineParser lineParser
-
state
private AbstractMessageParser.State state
-
message
private T extends HttpMessage message
-
lineBuf
private CharArrayBuffer lineBuf
-
headerBufs
private final java.util.List<CharArrayBuffer> headerBufs
-
emptyLineCount
private int emptyLineCount
-
-
Constructor Detail
-
AbstractMessageParser
public AbstractMessageParser(Http1Config http1Config, LineParser lineParser)
Constructs a new instance for a subclass.- Parameters:
http1Config- HTTP/1.1 protocol parameters.lineParser- How to parse lines in an HTTP message.- Since:
- 5.3
-
AbstractMessageParser
@Deprecated public AbstractMessageParser(LineParser lineParser, Http1Config messageConstraints)
Deprecated.Constructs a new instance for a subclass.- Parameters:
lineParser- How to parse lines in an HTTP message.messageConstraints- HTTP/1.1 protocol parameters.
-
-
Method Detail
-
getLineParser
LineParser getLineParser()
-
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 HttpMessage>
-
createMessage
protected abstract T createMessage(CharArrayBuffer buffer) throws HttpException
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:
HttpException- in case of HTTP protocol violation
-
parseHeadLine
private T parseHeadLine() throws java.io.IOException, HttpException
- Throws:
java.io.IOExceptionHttpException
-
parseHeader
private void parseHeader() throws java.io.IOException- Throws:
java.io.IOException
-
parse
public T parse(SessionInputBuffer sessionBuffer, boolean endOfStream) throws java.io.IOException, HttpException
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 HttpMessage>- Parameters:
sessionBuffer- session input buffer.endOfStream- end of stream flag- Returns:
- HTTP message head, if available,
nullotherwise. - Throws:
java.io.IOException- in case of an I/O error.HttpException- in case the HTTP message is malformed or violates the HTTP protocol.
-
-