mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponse.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/HttpResponse.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,160 @@
     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 java.util.Locale;
    1.34 +
    1.35 +/**
    1.36 + * After receiving and interpreting a request message, a server responds
    1.37 + * with an HTTP response message.
    1.38 + * <pre>
    1.39 + *     Response      = Status-Line
    1.40 + *                     *(( general-header
    1.41 + *                      | response-header
    1.42 + *                      | entity-header ) CRLF)
    1.43 + *                     CRLF
    1.44 + *                     [ message-body ]
    1.45 + * </pre>
    1.46 + *
    1.47 + * @since 4.0
    1.48 + */
    1.49 +public interface HttpResponse extends HttpMessage {
    1.50 +
    1.51 +    /**
    1.52 +     * Obtains the status line of this response.
    1.53 +     * The status line can be set using one of the
    1.54 +     * {@link #setStatusLine setStatusLine} methods,
    1.55 +     * or it can be initialized in a constructor.
    1.56 +     *
    1.57 +     * @return  the status line, or <code>null</code> if not yet set
    1.58 +     */
    1.59 +    StatusLine getStatusLine();
    1.60 +
    1.61 +    /**
    1.62 +     * Sets the status line of this response.
    1.63 +     *
    1.64 +     * @param statusline the status line of this response
    1.65 +     */
    1.66 +    void setStatusLine(StatusLine statusline);
    1.67 +
    1.68 +    /**
    1.69 +     * Sets the status line of this response.
    1.70 +     * The reason phrase will be determined based on the current
    1.71 +     * {@link #getLocale locale}.
    1.72 +     *
    1.73 +     * @param ver       the HTTP version
    1.74 +     * @param code      the status code
    1.75 +     */
    1.76 +    void setStatusLine(ProtocolVersion ver, int code);
    1.77 +
    1.78 +    /**
    1.79 +     * Sets the status line of this response with a reason phrase.
    1.80 +     *
    1.81 +     * @param ver       the HTTP version
    1.82 +     * @param code      the status code
    1.83 +     * @param reason    the reason phrase, or <code>null</code> to omit
    1.84 +     */
    1.85 +    void setStatusLine(ProtocolVersion ver, int code, String reason);
    1.86 +
    1.87 +    /**
    1.88 +     * Updates the status line of this response with a new status code.
    1.89 +     * The status line can only be updated if it is available. It must
    1.90 +     * have been set either explicitly or in a constructor.
    1.91 +     * <br/>
    1.92 +     * The reason phrase will be updated according to the new status code,
    1.93 +     * based on the current {@link #getLocale locale}. It can be set
    1.94 +     * explicitly using {@link #setReasonPhrase setReasonPhrase}.
    1.95 +     *
    1.96 +     * @param code the HTTP status code.
    1.97 +     *
    1.98 +     * @throws IllegalStateException
    1.99 +     *          if the status line has not be set
   1.100 +     *
   1.101 +     * @see HttpStatus
   1.102 +     * @see #setStatusLine(StatusLine)
   1.103 +     * @see #setStatusLine(ProtocolVersion,int)
   1.104 +     */
   1.105 +    void setStatusCode(int code)
   1.106 +        throws IllegalStateException;
   1.107 +
   1.108 +    /**
   1.109 +     * Updates the status line of this response with a new reason phrase.
   1.110 +     * The status line can only be updated if it is available. It must
   1.111 +     * have been set either explicitly or in a constructor.
   1.112 +     *
   1.113 +     * @param reason    the new reason phrase as a single-line string, or
   1.114 +     *                  <code>null</code> to unset the reason phrase
   1.115 +     *
   1.116 +     * @throws IllegalStateException
   1.117 +     *          if the status line has not be set
   1.118 +     *
   1.119 +     * @see #setStatusLine(StatusLine)
   1.120 +     * @see #setStatusLine(ProtocolVersion,int)
   1.121 +     */
   1.122 +    void setReasonPhrase(String reason)
   1.123 +        throws IllegalStateException;
   1.124 +
   1.125 +    /**
   1.126 +     * Obtains the message entity of this response, if any.
   1.127 +     * The entity is provided by calling {@link #setEntity setEntity}.
   1.128 +     *
   1.129 +     * @return  the response entity, or
   1.130 +     *          <code>null</code> if there is none
   1.131 +     */
   1.132 +    HttpEntity getEntity();
   1.133 +
   1.134 +    /**
   1.135 +     * Associates a response entity with this response.
   1.136 +     *
   1.137 +     * @param entity    the entity to associate with this response, or
   1.138 +     *                  <code>null</code> to unset
   1.139 +     */
   1.140 +    void setEntity(HttpEntity entity);
   1.141 +
   1.142 +    /**
   1.143 +     * Obtains the locale of this response.
   1.144 +     * The locale is used to determine the reason phrase
   1.145 +     * for the {@link #setStatusCode status code}.
   1.146 +     * It can be changed using {@link #setLocale setLocale}.
   1.147 +     *
   1.148 +     * @return  the locale of this response, never <code>null</code>
   1.149 +     */
   1.150 +    Locale getLocale();
   1.151 +
   1.152 +    /**
   1.153 +     * Changes the locale of this response.
   1.154 +     * If there is a status line, it's reason phrase will be updated
   1.155 +     * according to the status code and new locale.
   1.156 +     *
   1.157 +     * @param loc       the new locale
   1.158 +     *
   1.159 +     * @see #getLocale getLocale
   1.160 +     * @see #setStatusCode setStatusCode
   1.161 +     */
   1.162 +    void setLocale(Locale loc);
   1.163 +}

mercurial