mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpMessage.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpMessage.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,201 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib;
    1.32 +
    1.33 +import ch.boye.httpclientandroidlib.params.HttpParams;
    1.34 +
    1.35 +/**
    1.36 + * HTTP messages consist of requests from client to server and responses
    1.37 + * from server to client.
    1.38 + * <pre>
    1.39 + *     HTTP-message   = Request | Response     ; HTTP/1.1 messages
    1.40 + * </pre>
    1.41 + * <p>
    1.42 + * HTTP messages use the generic message format of RFC 822 for
    1.43 + * transferring entities (the payload of the message). Both types
    1.44 + * of message consist of a start-line, zero or more header fields
    1.45 + * (also known as "headers"), an empty line (i.e., a line with nothing
    1.46 + * preceding the CRLF) indicating the end of the header fields,
    1.47 + * and possibly a message-body.
    1.48 + * </p>
    1.49 + * <pre>
    1.50 + *      generic-message = start-line
    1.51 + *                        *(message-header CRLF)
    1.52 + *                        CRLF
    1.53 + *                        [ message-body ]
    1.54 + *      start-line      = Request-Line | Status-Line
    1.55 + * </pre>
    1.56 + *
    1.57 + * @since 4.0
    1.58 + */
    1.59 +public interface HttpMessage {
    1.60 +
    1.61 +    /**
    1.62 +     * Returns the protocol version this message is compatible with.
    1.63 +     */
    1.64 +    ProtocolVersion getProtocolVersion();
    1.65 +
    1.66 +    /**
    1.67 +     * Checks if a certain header is present in this message. Header values are
    1.68 +     * ignored.
    1.69 +     *
    1.70 +     * @param name the header name to check for.
    1.71 +     * @return true if at least one header with this name is present.
    1.72 +     */
    1.73 +    boolean containsHeader(String name);
    1.74 +
    1.75 +    /**
    1.76 +     * Returns all the headers with a specified name of this message. Header values
    1.77 +     * are ignored. Headers are orderd in the sequence they will be sent over a
    1.78 +     * connection.
    1.79 +     *
    1.80 +     * @param name the name of the headers to return.
    1.81 +     * @return the headers whose name property equals <code>name</code>.
    1.82 +     */
    1.83 +    Header[] getHeaders(String name);
    1.84 +
    1.85 +    /**
    1.86 +     * Returns the first header with a specified name of this message. Header
    1.87 +     * values are ignored. If there is more than one matching header in the
    1.88 +     * message the first element of {@link #getHeaders(String)} is returned.
    1.89 +     * If there is no matching header in the message <code>null</code> is
    1.90 +     * returned.
    1.91 +     *
    1.92 +     * @param name the name of the header to return.
    1.93 +     * @return the first header whose name property equals <code>name</code>
    1.94 +     *   or <code>null</code> if no such header could be found.
    1.95 +     */
    1.96 +    Header getFirstHeader(String name);
    1.97 +
    1.98 +    /**
    1.99 +     * Returns the last header with a specified name of this message. Header values
   1.100 +     * are ignored. If there is more than one matching header in the message the
   1.101 +     * last element of {@link #getHeaders(String)} is returned. If there is no
   1.102 +     * matching header in the message <code>null</code> is returned.
   1.103 +     *
   1.104 +     * @param name the name of the header to return.
   1.105 +     * @return the last header whose name property equals <code>name</code>.
   1.106 +     *   or <code>null</code> if no such header could be found.
   1.107 +     */
   1.108 +    Header getLastHeader(String name);
   1.109 +
   1.110 +    /**
   1.111 +     * Returns all the headers of this message. Headers are orderd in the sequence
   1.112 +     * they will be sent over a connection.
   1.113 +     *
   1.114 +     * @return all the headers of this message
   1.115 +     */
   1.116 +    Header[] getAllHeaders();
   1.117 +
   1.118 +    /**
   1.119 +     * Adds a header to this message. The header will be appended to the end of
   1.120 +     * the list.
   1.121 +     *
   1.122 +     * @param header the header to append.
   1.123 +     */
   1.124 +    void addHeader(Header header);
   1.125 +
   1.126 +    /**
   1.127 +     * Adds a header to this message. The header will be appended to the end of
   1.128 +     * the list.
   1.129 +     *
   1.130 +     * @param name the name of the header.
   1.131 +     * @param value the value of the header.
   1.132 +     */
   1.133 +    void addHeader(String name, String value);
   1.134 +
   1.135 +    /**
   1.136 +     * Overwrites the first header with the same name. The new header will be appended to
   1.137 +     * the end of the list, if no header with the given name can be found.
   1.138 +     *
   1.139 +     * @param header the header to set.
   1.140 +     */
   1.141 +    void setHeader(Header header);
   1.142 +
   1.143 +    /**
   1.144 +     * Overwrites the first header with the same name. The new header will be appended to
   1.145 +     * the end of the list, if no header with the given name can be found.
   1.146 +     *
   1.147 +     * @param name the name of the header.
   1.148 +     * @param value the value of the header.
   1.149 +     */
   1.150 +    void setHeader(String name, String value);
   1.151 +
   1.152 +    /**
   1.153 +     * Overwrites all the headers in the message.
   1.154 +     *
   1.155 +     * @param headers the array of headers to set.
   1.156 +     */
   1.157 +    void setHeaders(Header[] headers);
   1.158 +
   1.159 +    /**
   1.160 +     * Removes a header from this message.
   1.161 +     *
   1.162 +     * @param header the header to remove.
   1.163 +     */
   1.164 +    void removeHeader(Header header);
   1.165 +
   1.166 +    /**
   1.167 +     * Removes all headers with a certain name from this message.
   1.168 +     *
   1.169 +     * @param name The name of the headers to remove.
   1.170 +     */
   1.171 +    void removeHeaders(String name);
   1.172 +
   1.173 +    /**
   1.174 +     * Returns an iterator of all the headers.
   1.175 +     *
   1.176 +     * @return Iterator that returns Header objects in the sequence they are
   1.177 +     *         sent over a connection.
   1.178 +     */
   1.179 +    HeaderIterator headerIterator();
   1.180 +
   1.181 +    /**
   1.182 +     * Returns an iterator of the headers with a given name.
   1.183 +     *
   1.184 +     * @param name      the name of the headers over which to iterate, or
   1.185 +     *                  <code>null</code> for all headers
   1.186 +     *
   1.187 +     * @return Iterator that returns Header objects with the argument name
   1.188 +     *         in the sequence they are sent over a connection.
   1.189 +     */
   1.190 +    HeaderIterator headerIterator(String name);
   1.191 +
   1.192 +    /**
   1.193 +     * Returns the parameters effective for this message as set by
   1.194 +     * {@link #setParams(HttpParams)}.
   1.195 +     */
   1.196 +    HttpParams getParams();
   1.197 +
   1.198 +    /**
   1.199 +     * Provides parameters to be used for the processing of this message.
   1.200 +     * @param params the parameters
   1.201 +     */
   1.202 +    void setParams(HttpParams params);
   1.203 +
   1.204 +}

mercurial