2
* $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore/src/main/java/org/apache/http/message/LineParser.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.ParseException;
36
import org.apache.http.RequestLine;
37
import org.apache.http.StatusLine;
38
import org.apache.http.Header;
39
import org.apache.http.util.CharArrayBuffer;
42
* Interface for parsing lines in the HEAD section of an HTTP message.
43
* There are individual methods for parsing a request line, a
44
* status line, or a header line.
45
* The lines to parse are passed in memory, the parser does not depend
46
* on any specific IO mechanism.
47
* Instances of this interface are expected to be stateless and thread-safe.
51
* <!-- empty lines above to avoid 'svn diff' context problems -->
52
* @version $Revision: 744527 $ $Date: 2009-02-14 18:06:25 +0100 (Sat, 14 Feb 2009) $
56
public interface LineParser {
59
* Parses the textual representation of a protocol version.
60
* This is needed for parsing request lines (last element)
61
* as well as status lines (first element).
63
* @param buffer a buffer holding the protocol version to parse
64
* @param cursor the parser cursor containing the current position and
65
* the bounds within the buffer for the parsing operation
67
* @return the parsed protocol version
69
* @throws ParseException in case of a parse error
71
ProtocolVersion parseProtocolVersion(
72
CharArrayBuffer buffer,
73
ParserCursor cursor) throws ParseException;
76
* Checks whether there likely is a protocol version in a line.
77
* This method implements a <i>heuristic</i> to check for a
78
* likely protocol version specification. It does <i>not</i>
79
* guarantee that {@link #parseProtocolVersion} would not
80
* detect a parse error.
81
* This can be used to detect garbage lines before a request
84
* @param buffer a buffer holding the line to inspect
85
* @param cursor the cursor at which to check for a protocol version, or
86
* negative for "end of line". Whether the check tolerates
87
* whitespace before or after the protocol version is
88
* implementation dependent.
90
* @return <code>true</code> if there is a protocol version at the
91
* argument index (possibly ignoring whitespace),
92
* <code>false</code> otherwise
94
boolean hasProtocolVersion(
95
CharArrayBuffer buffer,
99
* Parses a request line.
101
* @param buffer a buffer holding the line to parse
102
* @param cursor the parser cursor containing the current position and
103
* the bounds within the buffer for the parsing operation
105
* @return the parsed request line
107
* @throws ParseException in case of a parse error
109
RequestLine parseRequestLine(
110
CharArrayBuffer buffer,
111
ParserCursor cursor) throws ParseException;
114
* Parses a status line.
116
* @param buffer a buffer holding the line to parse
117
* @param cursor the parser cursor containing the current position and
118
* the bounds within the buffer for the parsing operation
120
* @return the parsed status line
122
* @throws ParseException in case of a parse error
124
StatusLine parseStatusLine(
125
CharArrayBuffer buffer,
126
ParserCursor cursor) throws ParseException;
129
* Creates a header from a line.
130
* The full header line is expected here. Header continuation lines
131
* must be joined by the caller before invoking this method.
133
* @param buffer a buffer holding the full header line.
134
* This buffer MUST NOT be re-used afterwards, since
135
* the returned object may reference the contents later.
137
* @return the header in the argument buffer.
138
* The returned object MAY be a wrapper for the argument buffer.
139
* The argument buffer MUST NOT be re-used or changed afterwards.
141
* @throws ParseException in case of a parse error
143
Header parseHeader(CharArrayBuffer buffer)
144
throws ParseException;