public class BasicHttpResponse extends AbstractHttpMessage implements HttpResponse
HttpResponse
.DefaultHttpResponseFactory
headergroup, params
Constructor and Description |
---|
BasicHttpResponse(ProtocolVersion ver,
int code,
String reason)
Creates a response from elements of a status line.
|
BasicHttpResponse(StatusLine statusline)
Creates a response from a status line.
|
BasicHttpResponse(StatusLine statusline,
ReasonPhraseCatalog catalog,
Locale locale)
Creates a new response.
|
Modifier and Type | Method and Description |
---|---|
HttpEntity |
getEntity()
Obtains the message entity of this response, if any.
|
Locale |
getLocale()
Obtains the locale of this response.
|
ProtocolVersion |
getProtocolVersion()
Returns the protocol version this message is compatible with.
|
protected String |
getReason(int code)
Looks up a reason phrase.
|
StatusLine |
getStatusLine()
Obtains the status line of this response.
|
void |
setEntity(HttpEntity entity)
Associates a response entity with this response.
|
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 |
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.
|
String |
toString() |
addHeader, addHeader, containsHeader, getAllHeaders, getFirstHeader, getHeaders, getLastHeader, getParams, headerIterator, headerIterator, removeHeader, removeHeaders, setHeader, setHeader, setHeaders, setParams
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addHeader, addHeader, containsHeader, getAllHeaders, getFirstHeader, getHeaders, getLastHeader, getParams, headerIterator, headerIterator, removeHeader, removeHeaders, setHeader, setHeader, setHeaders, setParams
public BasicHttpResponse(StatusLine statusline, ReasonPhraseCatalog catalog, Locale locale)
statusline
- the status linecatalog
- 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(StatusLine statusline)
statusline
- the status linepublic BasicHttpResponse(ProtocolVersion ver, int code, String reason)
ver
- the protocol version of the responsecode
- the status code of the responsereason
- the reason phrase to the status code, or
null
public ProtocolVersion getProtocolVersion()
HttpMessage
getProtocolVersion
in interface HttpMessage
public StatusLine getStatusLine()
HttpResponse
setStatusLine
methods,
or it can be initialized in a constructor.getStatusLine
in interface HttpResponse
null
if not yet setpublic HttpEntity getEntity()
HttpResponse
setEntity
.getEntity
in interface HttpResponse
null
if there is nonepublic Locale getLocale()
HttpResponse
status code
.
It can be changed using setLocale
.getLocale
in interface HttpResponse
null
public void setStatusLine(StatusLine statusline)
HttpResponse
setStatusLine
in interface HttpResponse
statusline
- the status line of this responsepublic void setStatusLine(ProtocolVersion ver, int code)
HttpResponse
locale
.setStatusLine
in interface HttpResponse
ver
- the HTTP versioncode
- the status codepublic void setStatusLine(ProtocolVersion ver, int code, String reason)
HttpResponse
setStatusLine
in interface HttpResponse
ver
- the HTTP versioncode
- the status codereason
- the reason phrase, or null
to omitpublic void setStatusCode(int code)
HttpResponse
setStatusCode
in interface HttpResponse
code
- the HTTP status code.HttpStatus
,
HttpResponse.setStatusLine(StatusLine)
,
HttpResponse.setStatusLine(ProtocolVersion,int)
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 phraseHttpResponse.setStatusLine(StatusLine)
,
HttpResponse.setStatusLine(ProtocolVersion,int)
public void setEntity(HttpEntity entity)
HttpResponse
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.
setEntity
in interface HttpResponse
entity
- the entity to associate with this response, or
null
to unsetHttpEntity.isStreaming()
,
EntityUtils.updateEntity(HttpResponse, HttpEntity)
public 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 noneCopyright © 2005–2022 The Apache Software Foundation. All rights reserved.