public abstract class

AbstractMessageParser

extends Object
implements HttpMessageParser
java.lang.Object
   ↳ org.apache.http.impl.io.AbstractMessageParser
Known Direct Subclasses

Class Overview

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

The following parameters can be used to customize the behavior of this class:

Summary

Fields
protected final LineParser lineParser
Public Constructors
AbstractMessageParser(SessionInputBuffer buffer, LineParser parser, HttpParams params)
Creates an instance of this class.
Public Methods
HttpMessage parse()
Generates an instance of HttpMessage from the underlying data source.
static Header[] parseHeaders(SessionInputBuffer inbuffer, int maxHeaderCount, int maxLineLen, LineParser parser, List 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.
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.
Protected Methods
abstract HttpMessage parseHead(SessionInputBuffer sessionBuffer)
Subclasses must override this method to generate an instance of HttpMessage based on the initial input from the session buffer.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.io.HttpMessageParser

Fields

protected final LineParser lineParser

Public Constructors

public AbstractMessageParser (SessionInputBuffer buffer, LineParser parser, HttpParams params)

Creates an instance of this class.

Parameters
buffer the session input buffer.
parser the line parser.
params HTTP parameters.

Public Methods

public HttpMessage parse ()

Generates an instance of HttpMessage from the underlying data source.

Returns
  • HTTP message

public static Header[] parseHeaders (SessionInputBuffer inbuffer, int maxHeaderCount, int maxLineLen, LineParser parser, List 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.

Parameters
inbuffer Session input buffer
maxHeaderCount 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 java.io.InterruptedIOException.
Returns
  • array of HTTP headers
Throws
IOException in case of an I/O error
HttpException in case of HTTP protocol violation

public 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.

Parameters
inbuffer Session input buffer
maxHeaderCount 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.
Returns
  • array of HTTP headers
Throws
IOException in case of an I/O error
HttpException in case of HTTP protocol violation

Protected Methods

protected abstract HttpMessage parseHead (SessionInputBuffer sessionBuffer)

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 the session input buffer.
Returns
  • HTTP message based on the input from the session buffer.
Throws
IOException in case of an I/O error.
HttpException in case of HTTP protocol violation.
ParseException in case of a parse error.