2
* $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore/src/main/java/org/apache/http/message/LineFormatter.java $
4
* $Date: 2009-02-14 18:06:25 +0100 (Sat, 14 Feb 2009) $
6
* ====================================================================
7
* Licensed to the Apache Software Foundation (ASF) under one
8
* or more contributor license agreements. See the NOTICE file
9
* distributed with this work for additional information
10
* regarding copyright ownership. The ASF licenses this file
11
* to you under the Apache License, Version 2.0 (the
12
* "License"); you may not use this file except in compliance
13
* with the License. You may obtain a copy of the License at
15
* http://www.apache.org/licenses/LICENSE-2.0
17
* Unless required by applicable law or agreed to in writing,
18
* software distributed under the License is distributed on an
19
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
* KIND, either express or implied. See the License for the
21
* specific language governing permissions and limitations
23
* ====================================================================
25
* This software consists of voluntary contributions made by many
26
* individuals on behalf of the Apache Software Foundation. For more
27
* information on the Apache Software Foundation, please see
28
* <http://www.apache.org/>.
32
package org.apache.http.message;
34
import org.apache.http.ProtocolVersion;
35
import org.apache.http.RequestLine;
36
import org.apache.http.StatusLine;
37
import org.apache.http.Header;
38
import org.apache.http.util.CharArrayBuffer;
41
* Interface for formatting elements of the HEAD section of an HTTP message.
42
* This is the complement to {@link LineParser}.
43
* There are individual methods for formatting a request line, a
44
* status line, or a header line. The formatting does <i>not</i> include the
45
* trailing line break sequence CR-LF.
46
* Instances of this interface are expected to be stateless and thread-safe.
49
* The formatted lines are returned in memory, the formatter does not depend
50
* on any specific IO mechanism.
51
* In order to avoid unnecessary creation of temporary objects,
52
* a buffer can be passed as argument to all formatting methods.
53
* The implementation may or may not actually use that buffer for formatting.
54
* If it is used, the buffer will first be cleared by the
55
* <code>formatXXX</code> methods.
56
* The argument buffer can always be re-used after the call. The buffer
57
* returned as the result, if it is different from the argument buffer,
58
* MUST NOT be modified.
64
* <!-- empty lines above to avoid 'svn diff' context problems -->
65
* @version $Revision: 744527 $ $Date: 2009-02-14 18:06:25 +0100 (Sat, 14 Feb 2009) $
69
public interface LineFormatter {
72
* Formats a protocol version.
73
* This method does <i>not</i> follow the general contract for
74
* <code>buffer</code> arguments.
75
* It does <i>not</i> clear the argument buffer, but appends instead.
76
* The returned buffer can always be modified by the caller.
77
* Because of these differing conventions, it is not named
78
* <code>formatProtocolVersion</code>.
80
* @param buffer a buffer to which to append, or <code>null</code>
81
* @param version the protocol version to format
83
* @return a buffer with the formatted protocol version appended.
84
* The caller is allowed to modify the result buffer.
85
* If the <code>buffer</code> argument is not <code>null</code>,
86
* the returned buffer is the argument buffer.
88
CharArrayBuffer appendProtocolVersion(CharArrayBuffer buffer,
89
ProtocolVersion version);
92
* Formats a request line.
94
* @param buffer a buffer available for formatting, or
96
* The buffer will be cleared before use.
97
* @param reqline the request line to format
99
* @return the formatted request line
101
CharArrayBuffer formatRequestLine(CharArrayBuffer buffer,
102
RequestLine reqline);
105
* Formats a status line.
107
* @param buffer a buffer available for formatting, or
109
* The buffer will be cleared before use.
110
* @param statline the status line to format
112
* @return the formatted status line
114
* @throws ParseException in case of a parse error
116
CharArrayBuffer formatStatusLine(CharArrayBuffer buffer,
117
StatusLine statline);
121
* Due to header continuation, the result may be multiple lines.
122
* In order to generate well-formed HTTP, the lines in the result
123
* must be separated by the HTTP line break sequence CR-LF.
124
* There is <i>no</i> trailing CR-LF in the result.
126
* See the class comment for details about the buffer argument.
128
* @param buffer a buffer available for formatting, or
130
* The buffer will be cleared before use.
131
* @param header the header to format
133
* @return a buffer holding the formatted header, never <code>null</code>.
134
* The returned buffer may be different from the argument buffer.
136
* @throws ParseException in case of a parse error
138
CharArrayBuffer formatHeader(CharArrayBuffer buffer,