Top Description Fields Constructors Methods
org.apache.hc.core5.http.impl.io

public abstract Class AbstractMessageParser<T extends org.apache.hc.core5.http.HttpMessage>

extends Object
implements HttpMessageParser<T extends HttpMessage>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.io.HttpMessageParser
Known Direct Subclasses
org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser, org.apache.hc.core5.http.impl.io.DefaultHttpRequestParser
Imports
java.io.IOException, .InputStream, java.util.ArrayList, .List, org.apache.hc.core5.http.ConnectionClosedException, .Header, .HttpException, .HttpMessage, .MessageConstraintException, org.apache.hc.core5.http.config.Http1Config, org.apache.hc.core5.http.io.HttpMessageParser, .SessionInputBuffer, org.apache.hc.core5.http.message.LazyLineParser, .LineParser, org.apache.hc.core5.util.Args, .CharArrayBuffer

Abstract base class for HTTP message parsers that obtain input from an instance of org.apache.hc.core5.http.io.SessionInputBuffer.
Since
4.0

Field Summary

Modifier and TypeField and Description
private static final int
private final List<CharArrayBuffer>
private static final int
private final CharArrayBuffer
private final Http1Config
private final LineParser
private T
private int

Constructor Summary

AccessConstructor and Description
public
AbstractMessageParser(final LineParser
the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used.
lineParser
,
final Http1Config
the message http1Config. If null Http1Config#DEFAULT will be used.
http1Config
)

Creates new instance of AbstractMessageParser.

Method Summary

Modifier and TypeMethod and Description
protected IOException
createConnectionClosedException()

Deprecated do not use.
Subclasses must override this method to generate an appropriate exception in case of unexpected connection termination by the peer endpoint.
protected abstract T

Returns:

HTTP message based on the input from the session buffer.
createMessage
(CharArrayBuffer
the session input buffer.
buffer
)

Subclasses must override this method to generate an instance of HttpMessage based on the initial input from the session buffer.

pack-priv LineParser
public T
parse(final SessionInputBuffer
Session input buffer
buffer
,
final InputStream
Input stream
inputStream
)

Implements org.apache.hc.core5.http.io.HttpMessageParser.parse.

Generates an instance of MessageHeaders from the given input stream..
public static Header[]

Returns:

array of HTTP headers
parseHeaders
(final SessionInputBuffer
Session input buffer
inBuffer
,
final InputStream
Input stream
inputStream
,
final int
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.
maxHeaderCount
,
final int
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.
maxLineLen
,
final LineParser
the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used
lineParser
)

Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.

public static Header[]

Returns:

array of HTTP headers
parseHeaders
(final SessionInputBuffer
Session input buffer
inBuffer
,
final InputStream
Input stream
inputStream
,
final int
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.
maxHeaderCount
,
final int
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.
maxLineLen
,
final LineParser
line parser to use.
parser
,
final List<CharArrayBuffer>
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 java.io.InterruptedIOException.
headerLines
)

Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEAD_LINEback to summary
private static final int HEAD_LINE
headerLinesback to summary
private final List<CharArrayBuffer> headerLines
HEADERSback to summary
private static final int HEADERS
headLineback to summary
private final CharArrayBuffer headLine
http1Configback to summary
private final Http1Config http1Config
lineParserback to summary
private final LineParser lineParser
messageback to summary
private T message
stateback to summary
private int state

Constructor Detail

AbstractMessageParserback to summary
public AbstractMessageParser(final LineParser lineParser, final Http1Config http1Config)

Creates new instance of AbstractMessageParser.

Parameters
lineParser:LineParser

the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used.

http1Config:Http1Config

the message http1Config. If null Http1Config#DEFAULT will be used.

Since
4.3

Method Detail

createConnectionClosedExceptionback to summary
protected IOException createConnectionClosedException()

Deprecated

do not use.

Subclasses must override this method to generate an appropriate exception in case of unexpected connection termination by the peer endpoint.

Annotations
@Deprecated
Since
5.0
createMessageback to summary
protected abstract T createMessage(CharArrayBuffer buffer) throws IOException, HttpException

Subclasses must override this method to generate an instance of 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.

Parameters
buffer:CharArrayBuffer

the session input buffer.

Returns:T

HTTP message based on the input from the session buffer.

Exceptions
IOException:
in case of an I/O error.
HttpException:
in case of HTTP protocol violation.
Since
5.0
getLineParserback to summary
pack-priv LineParser getLineParser()
parseback to summary
public T parse(final SessionInputBuffer buffer, final InputStream inputStream) throws IOException, HttpException

Implements org.apache.hc.core5.http.io.HttpMessageParser.parse.

Doc from org.apache.hc.core5.http.io.HttpMessageParser.parse.

Generates an instance of MessageHeaders from the given input stream..

Parameters
buffer:SessionInputBuffer

Session input buffer

inputStream:InputStream

Input stream

Returns:T

HTTP message head or null if the input stream has been closed by the opposite endpoint.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error
HttpException:
in case of HTTP protocol violation
parseHeadersback to summary
public static Header[] parseHeaders(final SessionInputBuffer inBuffer, final InputStream inputStream, final int maxHeaderCount, final int maxLineLen, final LineParser lineParser) throws HttpException, IOException

Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.

Parameters
inBuffer:SessionInputBuffer

Session input buffer

inputStream:InputStream

Input stream

maxHeaderCount:int

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:int

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:LineParser

the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used

Returns:Header[]

array of HTTP headers

Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
parseHeadersback to summary
public static Header[] parseHeaders(final SessionInputBuffer inBuffer, final InputStream inputStream, final int maxHeaderCount, final int maxLineLen, final LineParser parser, final List<CharArrayBuffer> headerLines) throws HttpException, IOException

Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.

Parameters
inBuffer:SessionInputBuffer

Session input buffer

inputStream:InputStream

Input stream

maxHeaderCount:int

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:int

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:LineParser

line parser to use.

headerLines:List<CharArrayBuffer>

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 java.io.InterruptedIOException.

Returns:Header[]

array of HTTP headers

Exceptions
HttpException:
in case of HTTP protocol violation
IOException:
in case of an I/O error
Since
4.1