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

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

extends Object
implements HttpMessageParser<T extends HttpMessage>
Class Inheritance
All Implemented Interfaces
org.apache.http.io.HttpMessageParser
Known Direct Subclasses
org.apache.http.impl.io.DefaultHttpRequestParser, org.apache.http.impl.io.DefaultHttpResponseParser, org.apache.http.impl.io.HttpRequestParser, org.apache.http.impl.io.HttpResponseParser
Annotations
@SuppressWarnings:deprecation
Imports
java.io.IOException, java.util.ArrayList, .List, org.apache.http.Header, .HttpException, .HttpMessage, .MessageConstraintException, .ParseException, .ProtocolException, org.apache.http.config.MessageConstraints, org.apache.http.io.HttpMessageParser, .SessionInputBuffer, org.apache.http.message.BasicLineParser, .LineParser, org.apache.http.params.HttpParamConfig, .HttpParams, org.apache.http.util.Args, .CharArrayBuffer

Abstract base class for HTTP message parsers that obtain input from an instance of SessionInputBuffer.
Since
4.0

Field Summary

Modifier and TypeField and Description
private static final int
private final List<CharArrayBuffer>
private static final int
protected final LineParser
private T
private final MessageConstraints
private final SessionInputBuffer
private int

Constructor Summary

AccessConstructor and Description
public
AbstractMessageParser(final SessionInputBuffer
the session input buffer.
buffer
,
final LineParser
the line parser.
parser
,
final HttpParams
HTTP parameters.
params
)

Creates an instance of AbstractMessageParser.
public
AbstractMessageParser(final SessionInputBuffer
the session input buffer.
buffer
,
final LineParser
the line parser. If null BasicLineParser#INSTANCE will be used.
lineParser
,
final MessageConstraints
the message constraints. If null MessageConstraints#DEFAULT will be used.
constraints
)

Creates new instance of AbstractMessageParser.

Method Summary

Modifier and TypeMethod and Description
public T
parse()

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

Generates an instance of HttpMessage from the underlying data source.
protected abstract T

Returns:

HTTP message based on the input from the session buffer.
parseHead
(SessionInputBuffer
the session input buffer.
sessionBuffer
)

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

public static Header[]

Returns:

array of HTTP headers
parseHeaders
(final SessionInputBuffer
Session input buffer
inBuffer
,
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. Can be null, in which case the default implementation of this interface will be used.
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.

public static Header[]

Returns:

array of HTTP headers
parseHeaders
(final SessionInputBuffer
Session input buffer
inBuffer
,
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 given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.

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
lineParserback to summary
protected final LineParser lineParser
messageback to summary
private T message
messageConstraintsback to summary
private final MessageConstraints messageConstraints
sessionBufferback to summary
private final SessionInputBuffer sessionBuffer
stateback to summary
private int state

Constructor Detail

AbstractMessageParserback to summary
public AbstractMessageParser(final SessionInputBuffer buffer, final LineParser parser, final HttpParams params)

Creates an instance of AbstractMessageParser.

Parameters
buffer:SessionInputBuffer

the session input buffer.

parser:LineParser

the line parser.

params:HttpParams

HTTP parameters.

Annotations
@Deprecated
AbstractMessageParserback to summary
public AbstractMessageParser(final SessionInputBuffer buffer, final LineParser lineParser, final MessageConstraints constraints)

Creates new instance of AbstractMessageParser.

Parameters
buffer:SessionInputBuffer

the session input buffer.

lineParser:LineParser

the line parser. If null BasicLineParser#INSTANCE will be used.

constraints:MessageConstraints

the message constraints. If null MessageConstraints#DEFAULT will be used.

Since
4.3

Method Detail

parseback to summary
public T parse() throws IOException, HttpException

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

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

Generates an instance of HttpMessage from the underlying data source.

Returns:T

HTTP message

Annotations
@Override
Exceptions
IOException:
in case of an I/O error
HttpException:
in case of HTTP protocol violation
parseHeadback to summary
protected abstract T parseHead(SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException

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
sessionBuffer:SessionInputBuffer

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.
ParseException:
in case of a parse error.
parseHeadersback to summary
public static Header[] parseHeaders(final SessionInputBuffer inBuffer, final int maxHeaderCount, final int maxLineLen, final LineParser parser) throws HttpException, IOException

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.

Parameters
inBuffer:SessionInputBuffer

Session input buffer

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. Can be null, in which case the default implementation of this interface 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 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 given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.

Parameters
inBuffer:SessionInputBuffer

Session input buffer

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