org.apache.http.message.BasicLineFormatter
Interface for formatting elements of the HEAD section of an HTTP message.
This is the complement to LineParser.
There are individual methods for formatting a request line, a
status line, or a header line. The formatting does not include the
trailing line break sequence CR-LF.
The formatted lines are returned in memory, the formatter does not depend
on any specific IO mechanism.
Instances of this interface are expected to be stateless and thread-safe.
Summary
Constants
Public Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
A default instance of this class, for use as default or fallback.
Note that
BasicLineFormatter is not a singleton, there can
be many instances of the class itself and of derived classes.
The instance here provides non-customized, default behavior.
Public Constructors
public
BasicLineFormatter()
Public Methods
Formats a protocol version.
This method does not follow the general contract for
buffer
arguments.
It does not clear the argument buffer, but appends instead.
The returned buffer can always be modified by the caller.
Because of these differing conventions, it is not named
formatProtocolVersion
.
public
static
final
String
formatHeader(Header header, LineFormatter formatter)
Formats a header.
Parameters
header
| the header to format |
formatter
| the formatter to use, or
null for the
default |
Formats a header.
Due to header continuation, the result may be multiple lines.
In order to generate well-formed HTTP, the lines in the result
must be separated by the HTTP line break sequence CR-LF.
There is no trailing CR-LF in the result.
See the class comment for details about the buffer argument.
Formats a protocol version.
Parameters
version
| the protocol version to format |
formatter
| the formatter to use, or
null for the
default |
Returns
- the formatted protocol version
Formats a request line.
Parameters
reqline
| the request line to format |
formatter
| the formatter to use, or
null for the
default |
Returns
- the formatted request line
public
static
final
String
formatStatusLine(StatusLine statline, LineFormatter formatter)
Formats a status line.
Parameters
statline
| the status line to format |
formatter
| the formatter to use, or
null for the
default |
Returns
- the formatted status line
Protected Methods
protected
int
estimateProtocolVersionLen(ProtocolVersion version)
Guesses the length of a formatted protocol version.
Needed to guess the length of a formatted request or status line.
Parameters
version
| the protocol version to format, or null |
Returns
- the estimated length of the formatted protocol version,
in characters
Obtains a buffer for formatting.
Parameters
buffer
| a buffer already available, or null |
Returns
- the cleared argument buffer if there is one, or
a new empty buffer that can be used for formatting