Package org.apache.http
Interface HttpResponse
- All Superinterfaces:
HttpMessage
- All Known Subinterfaces:
CloseableHttpResponse
- All Known Implementing Classes:
BasicHttpResponse
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 TypeMethodDescriptionObtains the message entity of this response, if any.Obtains the locale of this response.Obtains the status line of this response.voidsetEntity(HttpEntity entity) Associates a response entity with this response.voidChanges the locale of this response.voidsetReasonPhrase(String reason) Updates the status line of this response with a new reason phrase.voidsetStatusCode(int code) Updates the status line of this response with a new status code.voidsetStatusLine(ProtocolVersion ver, int code) Sets the status line of this response.voidsetStatusLine(ProtocolVersion ver, int code, String reason) Sets the status line of this response with a reason phrase.voidsetStatusLine(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 Details
-
getStatusLine
StatusLine getStatusLine()Obtains the status line of this response. The status line can be set using one of thesetStatusLinemethods, or it can be initialized in a constructor.- Returns:
- the status line, or
nullif not yet set
-
setStatusLine
Sets the status line of this response.- Parameters:
statusline- the status line of this response
-
setStatusLine
Sets the status line of this response. The reason phrase will be determined based on the currentlocale.- Parameters:
ver- the HTTP versioncode- the status code
-
setStatusLine
Sets the status line of this response with a reason phrase.- Parameters:
ver- the HTTP versioncode- the status codereason- the reason phrase, ornullto omit
-
setStatusCode
Updates the status line of this response with a new status code.- Parameters:
code- the HTTP status code.- Throws:
IllegalStateException- if the status line has not be set- See Also:
-
setReasonPhrase
Updates the status line of this response with a new reason phrase.- Parameters:
reason- the new reason phrase as a single-line string, ornullto unset the reason phrase- Throws:
IllegalStateException- if the status line has not be set- See Also:
-
getEntity
HttpEntity getEntity()Obtains the message entity of this response, if any. The entity is provided by callingsetEntity.- Returns:
- the response entity, or
nullif there is none
-
setEntity
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()returnstrue), it must be fully consumed in order to ensure release of resources.- Parameters:
entity- the entity to associate with this response, ornullto unset- See Also:
-
getLocale
Locale getLocale()Obtains the locale of this response. The locale is used to determine the reason phrase for thestatus code. It can be changed usingsetLocale.- Returns:
- the locale of this response, never
null
-
setLocale
Changes the locale of this response.- Parameters:
loc- the new locale
-