public class BasicHttpResponse extends HeaderGroup implements HttpResponse
HttpResponse.| Constructor and Description |
|---|
BasicHttpResponse(int code)
Creates a new response.
|
BasicHttpResponse(int code,
ReasonPhraseCatalog catalog,
Locale locale)
Creates a new response.
|
BasicHttpResponse(int code,
String reasonPhrase)
Creates a new response.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
Object value)
Adds a header to this message.
|
int |
getCode()
Obtains the code of this response message.
|
Locale |
getLocale()
Obtains the locale of this response.
|
protected String |
getReason(int code)
Looks up a reason phrase.
|
String |
getReasonPhrase()
Obtains the reason phrase of this response if available.
|
ProtocolVersion |
getVersion()
Returns protocol version or
null when not available. |
void |
setCode(int code)
Updates status code of this response message.
|
void |
setHeader(String name,
Object value)
Overwrites the first header with the same name.
|
void |
setLocale(Locale locale)
Changes the locale of this response.
|
void |
setReasonPhrase(String reason)
Updates the status line of this response with a new reason phrase.
|
void |
setVersion(ProtocolVersion version)
Sets protocol version.
|
String |
toString() |
addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeadersclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddHeader, removeHeader, removeHeaders, setHeader, setHeaderscontainsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIteratorpublic BasicHttpResponse(int code,
ReasonPhraseCatalog catalog,
Locale locale)
code - the status codecatalog - the reason phrase catalog, or
null to disable automatic
reason phrase lookuplocale - the locale for looking up reason phrases, or
null for the system localepublic BasicHttpResponse(int code,
String reasonPhrase)
code - the status code of the responsereasonPhrase - the reason phrase to the status code, or nullpublic BasicHttpResponse(int code)
code - the status code of the responsepublic void addHeader(String name, Object value)
HttpMessageaddHeader in interface HttpMessagename - the name of the header.value - the value of the header, taken as the value's Object.toString().public void setHeader(String name, Object value)
HttpMessagesetHeader in interface HttpMessagename - the name of the header.value - the value of the header, taken as the value's Object.toString().public void setVersion(ProtocolVersion version)
HttpMessageFor incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
setVersion in interface HttpMessagepublic ProtocolVersion getVersion()
HttpMessagenull when not available.
For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
getVersion in interface HttpMessagepublic int getCode()
HttpResponsegetCode in interface HttpResponseHttpStatuspublic Locale getLocale()
HttpResponsestatus code.
It can be changed using setLocale.getLocale in interface HttpResponsenullpublic void setCode(int code)
HttpResponsesetCode in interface HttpResponsecode - the HTTP status code.HttpStatuspublic String getReasonPhrase()
HttpResponsegetReasonPhrase in interface HttpResponsepublic void setReasonPhrase(String reason)
HttpResponsesetReasonPhrase in interface HttpResponsereason - the new reason phrase as a single-line string, or
null to unset the reason phrasepublic void setLocale(Locale locale)
HttpResponsesetLocale in interface HttpResponselocale - the new localeprotected String getReason(int code)
code - the status code for which to look up the reasonnull if there is nonepublic String toString()
toString in class HeaderGroupCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.