mobile/android/thirdparty/ch/boye/httpclientandroidlib/message/LineFormatter.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

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.RequestLine;
michael@0 32 import ch.boye.httpclientandroidlib.StatusLine;
michael@0 33 import ch.boye.httpclientandroidlib.Header;
michael@0 34 import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
michael@0 35
michael@0 36 /**
michael@0 37 * Interface for formatting elements of the HEAD section of an HTTP message.
michael@0 38 * This is the complement to {@link LineParser}.
michael@0 39 * There are individual methods for formatting a request line, a
michael@0 40 * status line, or a header line. The formatting does <i>not</i> include the
michael@0 41 * trailing line break sequence CR-LF.
michael@0 42 * Instances of this interface are expected to be stateless and thread-safe.
michael@0 43 *
michael@0 44 * <p>
michael@0 45 * The formatted lines are returned in memory, the formatter does not depend
michael@0 46 * on any specific IO mechanism.
michael@0 47 * In order to avoid unnecessary creation of temporary objects,
michael@0 48 * a buffer can be passed as argument to all formatting methods.
michael@0 49 * The implementation may or may not actually use that buffer for formatting.
michael@0 50 * If it is used, the buffer will first be cleared by the
michael@0 51 * <code>formatXXX</code> methods.
michael@0 52 * The argument buffer can always be re-used after the call. The buffer
michael@0 53 * returned as the result, if it is different from the argument buffer,
michael@0 54 * MUST NOT be modified.
michael@0 55 * </p>
michael@0 56 *
michael@0 57 * @since 4.0
michael@0 58 */
michael@0 59 public interface LineFormatter {
michael@0 60
michael@0 61 /**
michael@0 62 * Formats a protocol version.
michael@0 63 * This method does <i>not</i> follow the general contract for
michael@0 64 * <code>buffer</code> arguments.
michael@0 65 * It does <i>not</i> clear the argument buffer, but appends instead.
michael@0 66 * The returned buffer can always be modified by the caller.
michael@0 67 * Because of these differing conventions, it is not named
michael@0 68 * <code>formatProtocolVersion</code>.
michael@0 69 *
michael@0 70 * @param buffer a buffer to which to append, or <code>null</code>
michael@0 71 * @param version the protocol version to format
michael@0 72 *
michael@0 73 * @return a buffer with the formatted protocol version appended.
michael@0 74 * The caller is allowed to modify the result buffer.
michael@0 75 * If the <code>buffer</code> argument is not <code>null</code>,
michael@0 76 * the returned buffer is the argument buffer.
michael@0 77 */
michael@0 78 CharArrayBuffer appendProtocolVersion(CharArrayBuffer buffer,
michael@0 79 ProtocolVersion version);
michael@0 80
michael@0 81 /**
michael@0 82 * Formats a request line.
michael@0 83 *
michael@0 84 * @param buffer a buffer available for formatting, or
michael@0 85 * <code>null</code>.
michael@0 86 * The buffer will be cleared before use.
michael@0 87 * @param reqline the request line to format
michael@0 88 *
michael@0 89 * @return the formatted request line
michael@0 90 */
michael@0 91 CharArrayBuffer formatRequestLine(CharArrayBuffer buffer,
michael@0 92 RequestLine reqline);
michael@0 93
michael@0 94 /**
michael@0 95 * Formats a status line.
michael@0 96 *
michael@0 97 * @param buffer a buffer available for formatting, or
michael@0 98 * <code>null</code>.
michael@0 99 * The buffer will be cleared before use.
michael@0 100 * @param statline the status line to format
michael@0 101 *
michael@0 102 * @return the formatted status line
michael@0 103 *
michael@0 104 * @throws ch.boye.httpclientandroidlib.ParseException in case of a parse error
michael@0 105 */
michael@0 106 CharArrayBuffer formatStatusLine(CharArrayBuffer buffer,
michael@0 107 StatusLine statline);
michael@0 108
michael@0 109 /**
michael@0 110 * Formats a header.
michael@0 111 * Due to header continuation, the result may be multiple lines.
michael@0 112 * In order to generate well-formed HTTP, the lines in the result
michael@0 113 * must be separated by the HTTP line break sequence CR-LF.
michael@0 114 * There is <i>no</i> trailing CR-LF in the result.
michael@0 115 * <br/>
michael@0 116 * See the class comment for details about the buffer argument.
michael@0 117 *
michael@0 118 * @param buffer a buffer available for formatting, or
michael@0 119 * <code>null</code>.
michael@0 120 * The buffer will be cleared before use.
michael@0 121 * @param header the header to format
michael@0 122 *
michael@0 123 * @return a buffer holding the formatted header, never <code>null</code>.
michael@0 124 * The returned buffer may be different from the argument buffer.
michael@0 125 *
michael@0 126 * @throws ch.boye.httpclientandroidlib.ParseException in case of a parse error
michael@0 127 */
michael@0 128 CharArrayBuffer formatHeader(CharArrayBuffer buffer,
michael@0 129 Header header);
michael@0 130
michael@0 131 }

mercurial