org.apache.http

## Interface HttpResponse

- All Superinterfaces:
    HttpMessage
  All Known Implementing Classes:
    BasicHttpResponse

      public interface HttpResponse
      extends HttpMessage

  After receiving and interpreting a request message, a server responds with an HTTP response message.

           Response      = Status-Line
                           *(( general-header
                            | response-header
                            | entity-header ) CRLF)
                           CRLF
                           [ message-body ]

  Since:
    4.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpEntity` | `getEntity()` Obtains the message entity of this response, if any.
    `Locale` | `getLocale()` Deprecated. (4.3) use `DefaultHttpRequestFactory`
    `StatusLine` | `getStatusLine()` Obtains the status line of this response.
    `void` | `setEntity(HttpEntity entity)` Associates a response entity with this response.
    `void` | `setLocale(Locale loc)` Deprecated. (4.3) use `DefaultHttpRequestFactory`
    `void` | `setReasonPhrase(String reason)` Updates the status line of this response with a new reason phrase.
    `void` | `setStatusCode(int code)` Updates the status line of this response with a new status code.
    `void` | `setStatusLine(ProtocolVersion ver, int code)` Sets the status line of this response.
    `void` | `setStatusLine(ProtocolVersion ver, int code, String reason)` Sets the status line of this response with a reason phrase.
    `void` | `setStatusLine(StatusLine statusline)` Sets the status line of this response.

    - ### Methods inherited from interface org.apache.http.HttpMessage

      `addHeader, addHeader, containsHeader, getAllHeaders, getFirstHeader, getHeaders, getLastHeader, getParams, getProtocolVersion, headerIterator, headerIterator, removeHeader, removeHeaders, setHeader, setHeader, setHeaders, setParams`

- - ### Method Detail

    - #### getStatusLine

          StatusLine getStatusLine()

      Obtains the status line of this response. The status line can be set using one of the `setStatusLine` methods, or it can be initialized in a constructor.
      Returns:
        the status line, or `null` if not yet set

    - #### setStatusLine

          void setStatusLine(StatusLine statusline)

      Sets the status line of this response.
      Parameters:
        `statusline` - the status line of this response

    - #### setStatusLine

          void setStatusLine(ProtocolVersion ver,
                           int code)

      Sets the status line of this response. The reason phrase will be determined based on the current `locale`.
      Parameters:
        `ver` - the HTTP version
        `code` - the status code

    - #### setStatusLine

          void setStatusLine(ProtocolVersion ver,
                           int code,
                           String reason)

      Sets the status line of this response with a reason phrase.
      Parameters:
        `ver` - the HTTP version
        `code` - the status code
        `reason` - the reason phrase, or `null` to omit

    - #### setStatusCode

          void setStatusCode(int code)
                             throws IllegalStateException

      Updates the status line of this response with a new status code. The status line can only be updated if it is available. It must have been set either explicitly or in a constructor.
      The reason phrase will be updated according to the new status code, based on the current `locale`. It can be set explicitly using `setReasonPhrase`.
      Parameters:
        `code` - the HTTP status code.
      Throws:
        `IllegalStateException` - if the status line has not be set
      See Also:
        `HttpStatus`, `setStatusLine(StatusLine)`, `setStatusLine(ProtocolVersion,int)`

    - #### setReasonPhrase

          void setReasonPhrase(String reason)
                               throws IllegalStateException

      Updates the status line of this response with a new reason phrase. The status line can only be updated if it is available. It must have been set either explicitly or in a constructor.
      Parameters:
        `reason` - the new reason phrase as a single-line string, or `null` to unset the reason phrase
      Throws:
        `IllegalStateException` - if the status line has not be set
      See Also:
        `setStatusLine(StatusLine)`, `setStatusLine(ProtocolVersion,int)`

    - #### getEntity

          HttpEntity getEntity()

      Obtains the message entity of this response, if any. The entity is provided by calling `setEntity`.
      Returns:
        the response entity, or `null` if there is none

    - #### setEntity

          void setEntity(HttpEntity entity)

      Associates a response entity with this response.

      Please note that if an entity has already been set for this response and it depends on an input stream (`HttpEntity.isStreaming()` returns `true`), it must be fully consumed in order to ensure release of resources.
      Parameters:
        `entity` - the entity to associate with this response, or `null` to unset
      See Also:
        `HttpEntity.isStreaming()`, `EntityUtils.updateEntity(HttpResponse, HttpEntity)`

    - #### getLocale

          @Deprecated
          Locale getLocale()

      Deprecated. (4.3) use `DefaultHttpRequestFactory`
      Obtains the locale of this response. The locale is used to determine the reason phrase for the `status code`. It can be changed using `setLocale`.
      Returns:
        the locale of this response, never `null`

    - #### setLocale

          @Deprecated
          void setLocale(Locale loc)

      Deprecated. (4.3) use `DefaultHttpRequestFactory`
      Changes the locale of this response. If there is a status line, it's reason phrase will be updated according to the status code and new locale.
      Parameters:
        `loc` - the new locale

Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.