@NotThreadSafe public abstract class AbstractMessageParser<T extends HttpMessage> extends java.lang.Object implements HttpMessageParser<T>
SessionInputBuffer
.Modifier and Type | Field and Description |
---|---|
protected LineParser |
lineParser |
Constructor and Description |
---|
AbstractMessageParser(SessionInputBuffer buffer,
LineParser parser,
HttpParams params)
Deprecated.
|
AbstractMessageParser(SessionInputBuffer buffer,
LineParser lineParser,
MessageConstraints constraints)
Creates new instance of AbstractMessageParser.
|
Modifier and Type | Method and Description |
---|---|
T |
parse()
Generates an instance of
HttpMessage from the underlying data
source. |
protected abstract T |
parseHead(SessionInputBuffer sessionBuffer)
Subclasses must override this method to generate an instance of
HttpMessage based on the initial input from the session buffer. |
static Header[] |
parseHeaders(SessionInputBuffer inbuffer,
int maxHeaderCount,
int maxLineLen,
LineParser parser)
Parses HTTP headers from the data receiver stream according to the generic
format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
|
static Header[] |
parseHeaders(SessionInputBuffer inbuffer,
int maxHeaderCount,
int maxLineLen,
LineParser parser,
java.util.List<CharArrayBuffer> headerLines)
Parses HTTP headers from the data receiver stream according to the generic
format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
|
protected final LineParser lineParser
@Deprecated public AbstractMessageParser(SessionInputBuffer buffer, LineParser parser, HttpParams params)
AbstractMessageParser(SessionInputBuffer,
LineParser, MessageConstraints)
buffer
- the session input buffer.parser
- the line parser.params
- HTTP parameters.public AbstractMessageParser(SessionInputBuffer buffer, LineParser lineParser, MessageConstraints constraints)
buffer
- the session input buffer.lineParser
- the line parser. If null
BasicLineParser.INSTANCE
will be used.constraints
- the message constraints. If null
MessageConstraints.DEFAULT
will be used.public static Header[] parseHeaders(SessionInputBuffer inbuffer, int maxHeaderCount, int maxLineLen, LineParser parser) throws HttpException, java.io.IOException
inbuffer
- Session input buffermaxHeaderCount
- maximum number of headers allowed. If the number
of headers received from the data stream exceeds maxCount value, an
IOException will be thrown. Setting this parameter to a negative value
or zero will disable the check.maxLineLen
- maximum number of characters for a header line,
including the continuation lines. Setting this parameter to a negative
value or zero will disable the check.parser
- line parser to use. Can be null
, in which case
the default implementation of this interface will be used.java.io.IOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violationpublic static Header[] parseHeaders(SessionInputBuffer inbuffer, int maxHeaderCount, int maxLineLen, LineParser parser, java.util.List<CharArrayBuffer> headerLines) throws HttpException, java.io.IOException
inbuffer
- Session input buffermaxHeaderCount
- maximum number of headers allowed. If the number
of headers received from the data stream exceeds maxCount value, an
IOException will be thrown. Setting this parameter to a negative value
or zero will disable the check.maxLineLen
- maximum number of characters for a header line,
including the continuation lines. Setting this parameter to a negative
value or zero will disable the check.parser
- line parser to use.headerLines
- List of header lines. This list will be used to store
intermediate results. This makes it possible to resume parsing of
headers in case of a InterruptedIOException
.java.io.IOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violationprotected abstract T parseHead(SessionInputBuffer sessionBuffer) throws java.io.IOException, HttpException, ParseException
HttpMessage
based on the initial input from the session buffer.
Usually this method is expected to read just the very first line or
the very first valid from the data stream and based on the input generate
an appropriate instance of HttpMessage
.
sessionBuffer
- the session input buffer.java.io.IOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation.ParseException
- in case of a parse error.public T parse() throws java.io.IOException, HttpException
HttpMessageParser
HttpMessage
from the underlying data
source.parse
in interface HttpMessageParser<T extends HttpMessage>
java.io.IOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violation