Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | * ==================================================================== |
michael@0 | 3 | * Licensed to the Apache Software Foundation (ASF) under one |
michael@0 | 4 | * or more contributor license agreements. See the NOTICE file |
michael@0 | 5 | * distributed with this work for additional information |
michael@0 | 6 | * regarding copyright ownership. The ASF licenses this file |
michael@0 | 7 | * to you under the Apache License, Version 2.0 (the |
michael@0 | 8 | * "License"); you may not use this file except in compliance |
michael@0 | 9 | * with the License. You may obtain a copy of the License at |
michael@0 | 10 | * |
michael@0 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 12 | * |
michael@0 | 13 | * Unless required by applicable law or agreed to in writing, |
michael@0 | 14 | * software distributed under the License is distributed on an |
michael@0 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
michael@0 | 16 | * KIND, either express or implied. See the License for the |
michael@0 | 17 | * specific language governing permissions and limitations |
michael@0 | 18 | * under the License. |
michael@0 | 19 | * ==================================================================== |
michael@0 | 20 | * |
michael@0 | 21 | * This software consists of voluntary contributions made by many |
michael@0 | 22 | * individuals on behalf of the Apache Software Foundation. For more |
michael@0 | 23 | * information on the Apache Software Foundation, please see |
michael@0 | 24 | * <http://www.apache.org/>. |
michael@0 | 25 | * |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | package ch.boye.httpclientandroidlib.message; |
michael@0 | 29 | |
michael@0 | 30 | import ch.boye.httpclientandroidlib.ProtocolVersion; |
michael@0 | 31 | import ch.boye.httpclientandroidlib.ParseException; |
michael@0 | 32 | import ch.boye.httpclientandroidlib.RequestLine; |
michael@0 | 33 | import ch.boye.httpclientandroidlib.StatusLine; |
michael@0 | 34 | import ch.boye.httpclientandroidlib.Header; |
michael@0 | 35 | import ch.boye.httpclientandroidlib.util.CharArrayBuffer; |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Interface for parsing lines in the HEAD section of an HTTP message. |
michael@0 | 39 | * There are individual methods for parsing a request line, a |
michael@0 | 40 | * status line, or a header line. |
michael@0 | 41 | * The lines to parse are passed in memory, the parser does not depend |
michael@0 | 42 | * on any specific IO mechanism. |
michael@0 | 43 | * Instances of this interface are expected to be stateless and thread-safe. |
michael@0 | 44 | * |
michael@0 | 45 | * @since 4.0 |
michael@0 | 46 | */ |
michael@0 | 47 | public interface LineParser { |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Parses the textual representation of a protocol version. |
michael@0 | 51 | * This is needed for parsing request lines (last element) |
michael@0 | 52 | * as well as status lines (first element). |
michael@0 | 53 | * |
michael@0 | 54 | * @param buffer a buffer holding the protocol version to parse |
michael@0 | 55 | * @param cursor the parser cursor containing the current position and |
michael@0 | 56 | * the bounds within the buffer for the parsing operation |
michael@0 | 57 | * |
michael@0 | 58 | * @return the parsed protocol version |
michael@0 | 59 | * |
michael@0 | 60 | * @throws ParseException in case of a parse error |
michael@0 | 61 | */ |
michael@0 | 62 | ProtocolVersion parseProtocolVersion( |
michael@0 | 63 | CharArrayBuffer buffer, |
michael@0 | 64 | ParserCursor cursor) throws ParseException; |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Checks whether there likely is a protocol version in a line. |
michael@0 | 68 | * This method implements a <i>heuristic</i> to check for a |
michael@0 | 69 | * likely protocol version specification. It does <i>not</i> |
michael@0 | 70 | * guarantee that {@link #parseProtocolVersion} would not |
michael@0 | 71 | * detect a parse error. |
michael@0 | 72 | * This can be used to detect garbage lines before a request |
michael@0 | 73 | * or status line. |
michael@0 | 74 | * |
michael@0 | 75 | * @param buffer a buffer holding the line to inspect |
michael@0 | 76 | * @param cursor the cursor at which to check for a protocol version, or |
michael@0 | 77 | * negative for "end of line". Whether the check tolerates |
michael@0 | 78 | * whitespace before or after the protocol version is |
michael@0 | 79 | * implementation dependent. |
michael@0 | 80 | * |
michael@0 | 81 | * @return <code>true</code> if there is a protocol version at the |
michael@0 | 82 | * argument index (possibly ignoring whitespace), |
michael@0 | 83 | * <code>false</code> otherwise |
michael@0 | 84 | */ |
michael@0 | 85 | boolean hasProtocolVersion( |
michael@0 | 86 | CharArrayBuffer buffer, |
michael@0 | 87 | ParserCursor cursor); |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Parses a request line. |
michael@0 | 91 | * |
michael@0 | 92 | * @param buffer a buffer holding the line to parse |
michael@0 | 93 | * @param cursor the parser cursor containing the current position and |
michael@0 | 94 | * the bounds within the buffer for the parsing operation |
michael@0 | 95 | * |
michael@0 | 96 | * @return the parsed request line |
michael@0 | 97 | * |
michael@0 | 98 | * @throws ParseException in case of a parse error |
michael@0 | 99 | */ |
michael@0 | 100 | RequestLine parseRequestLine( |
michael@0 | 101 | CharArrayBuffer buffer, |
michael@0 | 102 | ParserCursor cursor) throws ParseException; |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Parses a status line. |
michael@0 | 106 | * |
michael@0 | 107 | * @param buffer a buffer holding the line to parse |
michael@0 | 108 | * @param cursor the parser cursor containing the current position and |
michael@0 | 109 | * the bounds within the buffer for the parsing operation |
michael@0 | 110 | * |
michael@0 | 111 | * @return the parsed status line |
michael@0 | 112 | * |
michael@0 | 113 | * @throws ParseException in case of a parse error |
michael@0 | 114 | */ |
michael@0 | 115 | StatusLine parseStatusLine( |
michael@0 | 116 | CharArrayBuffer buffer, |
michael@0 | 117 | ParserCursor cursor) throws ParseException; |
michael@0 | 118 | |
michael@0 | 119 | /** |
michael@0 | 120 | * Creates a header from a line. |
michael@0 | 121 | * The full header line is expected here. Header continuation lines |
michael@0 | 122 | * must be joined by the caller before invoking this method. |
michael@0 | 123 | * |
michael@0 | 124 | * @param buffer a buffer holding the full header line. |
michael@0 | 125 | * This buffer MUST NOT be re-used afterwards, since |
michael@0 | 126 | * the returned object may reference the contents later. |
michael@0 | 127 | * |
michael@0 | 128 | * @return the header in the argument buffer. |
michael@0 | 129 | * The returned object MAY be a wrapper for the argument buffer. |
michael@0 | 130 | * The argument buffer MUST NOT be re-used or changed afterwards. |
michael@0 | 131 | * |
michael@0 | 132 | * @throws ParseException in case of a parse error |
michael@0 | 133 | */ |
michael@0 | 134 | Header parseHeader(CharArrayBuffer buffer) |
michael@0 | 135 | throws ParseException; |
michael@0 | 136 | |
michael@0 | 137 | } |