Interface for parsing lines in the HEAD section of an HTTP message. More...
There are individual methods for parsing a request line, a status line, or a header line. The lines to parse are passed in memory, the parser does not depend on any specific IO mechanism. Instances of this interface are expected to be stateless and thread-safe.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
ProtocolVersion | parseProtocolVersion (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException |
Parses the textual representation of a protocol version. More... | |
boolean | hasProtocolVersion (CharArrayBuffer buffer, ParserCursor cursor) |
Checks whether there likely is a protocol version in a line. More... | |
RequestLine | parseRequestLine (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException |
Parses a request line. More... | |
StatusLine | parseStatusLine (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException |
Parses a status line. More... | |
Header | parseHeader (CharArrayBuffer buffer) throws ParseException |
Creates a header from a line. More... | |
ProtocolVersion parseProtocolVersion | ( | CharArrayBuffer | buffer, |
ParserCursor | cursor | ||
) | throws ParseException |
This is needed for parsing request lines (last element) as well as status lines (first element).
buffer | a buffer holding the protocol version to parse |
cursor | the parser cursor containing the current position and the bounds within the buffer for the parsing operation |
ParseException | in case of a parse error |
Implemented in BasicLineParser.
boolean hasProtocolVersion | ( | CharArrayBuffer | buffer, |
ParserCursor | cursor | ||
) |
This method implements a heuristic to check for a likely protocol version specification. It does not guarantee that parseProtocolVersion would not detect a parse error. This can be used to detect garbage lines before a request or status line.
buffer | a buffer holding the line to inspect |
cursor | the cursor at which to check for a protocol version, or negative for "end of line". Whether the check tolerates whitespace before or after the protocol version is implementation dependent. |
true
if there is a protocol version at the argument index (possibly ignoring whitespace), false
otherwise Implemented in BasicLineParser.
RequestLine parseRequestLine | ( | CharArrayBuffer | buffer, |
ParserCursor | cursor | ||
) | throws ParseException |
buffer | a buffer holding the line to parse |
cursor | the parser cursor containing the current position and the bounds within the buffer for the parsing operation |
ParseException | in case of a parse error |
Implemented in BasicLineParser.
StatusLine parseStatusLine | ( | CharArrayBuffer | buffer, |
ParserCursor | cursor | ||
) | throws ParseException |
buffer | a buffer holding the line to parse |
cursor | the parser cursor containing the current position and the bounds within the buffer for the parsing operation |
ParseException | in case of a parse error |
Implemented in BasicLineParser.
Header parseHeader | ( | CharArrayBuffer | buffer | ) | throws ParseException |
The full header line is expected here. Header continuation lines must be joined by the caller before invoking this method.
buffer | a buffer holding the full header line. This buffer MUST NOT be re-used afterwards, since the returned object may reference the contents later. |
ParseException | in case of a parse error |
Implemented in BasicLineParser.