Top Description Methods
org.apache.http

public Interface HttpResponse

extends HttpMessage
Known Direct Implementers
org.apache.http.message.BasicHttpResponse
Imports
java.util.Locale

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

Modifier and TypeMethod and Description
public HttpEntity

Returns:

the response entity, or null if there is none
getEntity
()

Obtains the message entity of this response, if any.

public Locale

Returns:

the locale of this response, never null
getLocale
()

Obtains the locale of this response.

public StatusLine

Returns:

the status line, or null if not yet set
getStatusLine
()

Obtains the status line of this response.

public void
setEntity(HttpEntity
the entity to associate with this response, or null to unset
entity
)

Associates a response entity with this response.

public void
setLocale(Locale
the new locale
loc
)

Changes the locale of this response.

public void
setReasonPhrase(String
the new reason phrase as a single-line string, or null to unset the reason phrase
reason
)

Updates the status line of this response with a new reason phrase.

public void
setStatusCode(int
the HTTP status code.
code
)

Updates the status line of this response with a new status code.

public void
setStatusLine(StatusLine
the status line of this response
statusline
)

Sets the status line of this response.

public void
setStatusLine(ProtocolVersion
the HTTP version
ver
,
int
the status code
code
)

Sets the status line of this response.

public void
setStatusLine(ProtocolVersion
the HTTP version
ver
,
int
the status code
code
,
String
the reason phrase, or null to omit
reason
)

Sets the status line of this response with a reason phrase.

Inherited from org.apache.http.HttpMessage:
addHeaderaddHeadercontainsHeadergetAllHeadersgetFirstHeadergetHeadersgetLastHeadergetParamsgetProtocolVersionheaderIteratorheaderIteratorremoveHeaderremoveHeaderssetHeadersetHeadersetHeaderssetParams

Method Detail

getEntityback to summary
public HttpEntity getEntity()

Obtains the message entity of this response, if any. The entity is provided by calling setEntity.

Returns:HttpEntity

the response entity, or null if there is none

getLocaleback to summary
public Locale getLocale()

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:Locale

the locale of this response, never null

getStatusLineback to summary
public 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:StatusLine

the status line, or null if not yet set

setEntityback to summary
public 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:HttpEntity

the entity to associate with this response, or null to unset

See Also
HttpEntity#isStreaming(), org.apache.http.util.EntityUtils#updateEntity(HttpResponse, HttpEntity)
setLocaleback to summary
public void setLocale(Locale loc)

Changes the locale of this response.

Parameters
loc:Locale

the new locale

setReasonPhraseback to summary
public void setReasonPhrase(String reason) throws IllegalStateException

Updates the status line of this response with a new reason phrase.

Parameters
reason:String

the new reason phrase as a single-line string, or null to unset the reason phrase

Exceptions
IllegalStateException:
if the status line has not be set
See Also
setStatusLine(StatusLine), setStatusLine(ProtocolVersion, int)
setStatusCodeback to summary
public void setStatusCode(int code) throws IllegalStateException

Updates the status line of this response with a new status code.

Parameters
code:int

the HTTP status code.

Exceptions
IllegalStateException:
if the status line has not be set
See Also
HttpStatus, setStatusLine(StatusLine), setStatusLine(ProtocolVersion, int)
setStatusLineback to summary
public void setStatusLine(StatusLine statusline)

Sets the status line of this response.

Parameters
statusline:StatusLine

the status line of this response

setStatusLineback to summary
public 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:ProtocolVersion

the HTTP version

code:int

the status code

setStatusLineback to summary
public void setStatusLine(ProtocolVersion ver, int code, String reason)

Sets the status line of this response with a reason phrase.

Parameters
ver:ProtocolVersion

the HTTP version

code:int

the status code

reason:String

the reason phrase, or null to omit