public abstract class AbstractMessageParser<T extends HttpMessage> extends Object implements HttpMessageParser<T>
SessionInputBuffer
.Constructor and Description |
---|
AbstractMessageParser(LineParser lineParser,
Http1Config http1Config)
Creates new instance of AbstractMessageParser.
|
Modifier and Type | Method and Description |
---|---|
protected abstract IOException |
createConnectionClosedException()
Subclasses must override this method to generate an appropriate exception
in case of unexpected connection termination by the peer endpoint.
|
protected abstract T |
createMessage(CharArrayBuffer buffer)
Subclasses must override this method to generate an instance of
HttpMessage based on the initial input from the session buffer. |
T |
parse(SessionInputBuffer buffer,
InputStream inputStream)
Generates an instance of
MessageHeaders from the given input stream.. |
static Header[] |
parseHeaders(SessionInputBuffer inBuffer,
InputStream inputStream,
int maxHeaderCount,
int maxLineLen,
LineParser lineParser)
Parses HTTP headers from the data receiver stream according to the generic
format as specified by the HTTP/1.1 protocol specification.
|
static Header[] |
parseHeaders(SessionInputBuffer inBuffer,
InputStream inputStream,
int maxHeaderCount,
int maxLineLen,
LineParser parser,
List<CharArrayBuffer> headerLines)
Parses HTTP headers from the data receiver stream according to the generic
format as specified by the HTTP/1.1 protocol specification.
|
public AbstractMessageParser(LineParser lineParser, Http1Config http1Config)
lineParser
- the line parser. If null
LazyLineParser.INSTANCE
will be used.http1Config
- the message http1Config. If null
Http1Config.DEFAULT
will be used.public static Header[] parseHeaders(SessionInputBuffer inBuffer, InputStream inputStream, int maxHeaderCount, int maxLineLen, LineParser lineParser) throws HttpException, IOException
inBuffer
- Session input bufferinputStream
- Input streammaxHeaderCount
- 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.lineParser
- the line parser. If null
LazyLineParser.INSTANCE
will be usedIOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violationpublic static Header[] parseHeaders(SessionInputBuffer inBuffer, InputStream inputStream, int maxHeaderCount, int maxLineLen, LineParser parser, List<CharArrayBuffer> headerLines) throws HttpException, IOException
inBuffer
- Session input bufferinputStream
- Input streammaxHeaderCount
- 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
.IOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violationprotected abstract T createMessage(CharArrayBuffer buffer) throws IOException, HttpException
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
.
buffer
- the session input buffer.IOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation.protected abstract IOException createConnectionClosedException()
public T parse(SessionInputBuffer buffer, InputStream inputStream) throws IOException, HttpException
HttpMessageParser
MessageHeaders
from the given input stream..parse
in interface HttpMessageParser<T extends HttpMessage>
buffer
- Session input bufferinputStream
- Input streamIOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violationCopyright © 2005–2022 The Apache Software Foundation. All rights reserved.