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, setHeaders
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addHeader, removeHeader, removeHeaders, setHeader, setHeaders
containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator
public 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 null
public BasicHttpResponse(int code)
code
- the status code of the responsepublic void addHeader(String name, Object value)
HttpMessage
addHeader
in interface HttpMessage
name
- 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)
HttpMessage
setHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header, taken as the value's Object.toString()
.public void setVersion(ProtocolVersion version)
HttpMessage
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.
setVersion
in interface HttpMessage
version
- The protocol version.public ProtocolVersion getVersion()
HttpMessage
null
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 HttpMessage
public int getCode()
HttpResponse
getCode
in interface HttpResponse
HttpStatus
public Locale getLocale()
HttpResponse
status code
.
It can be changed using setLocale
.getLocale
in interface HttpResponse
null
public void setCode(int code)
HttpResponse
setCode
in interface HttpResponse
code
- the HTTP status code.HttpStatus
public String getReasonPhrase()
HttpResponse
getReasonPhrase
in interface HttpResponse
public void setReasonPhrase(String reason)
HttpResponse
setReasonPhrase
in interface HttpResponse
reason
- the new reason phrase as a single-line string, or
null
to unset the reason phrasepublic void setLocale(Locale locale)
HttpResponse
setLocale
in interface HttpResponse
locale
- 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 HeaderGroup
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.