@NotThreadSafe 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)
Deprecated.
(4.3) use
DefaultHttpRequestFactory |
Modifier and Type | Method and Description |
---|---|
HttpEntity |
getEntity()
Obtains the message entity of this response, if any.
|
Locale |
getLocale()
Deprecated.
(4.3) use
DefaultHttpRequestFactory |
ProtocolVersion |
getProtocolVersion()
Returns the protocol version this message is compatible with.
|
protected String |
getReason(int code)
Deprecated.
(4.3) use
DefaultHttpRequestFactory |
StatusLine |
getStatusLine()
Obtains the status line of this response.
|
void |
setEntity(HttpEntity entity)
Associates a response entity with this response.
|
void |
setLocale(Locale locale)
Deprecated.
(4.3) use
DefaultHttpRequestFactory |
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
@Deprecated public BasicHttpResponse(StatusLine statusline, ReasonPhraseCatalog catalog, Locale locale)
DefaultHttpRequestFactory
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 none@Deprecated public Locale getLocale()
DefaultHttpRequestFactory
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
locale
. It can be set
explicitly using setReasonPhrase
.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
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)
@Deprecated public void setLocale(Locale locale)
DefaultHttpRequestFactory
HttpResponse
setLocale
in interface HttpResponse
locale
- the new locale@Deprecated protected String getReason(int code)
DefaultHttpRequestFactory
code
- the status code for which to look up the reasonnull
if there is noneCopyright © 2005–2013 The Apache Software Foundation. All rights reserved.