@NotThreadSafe class HttpResponseProxy extends java.lang.Object implements CloseableHttpResponse
HttpResponse
that can be used to release client connection
associated with the original response.Constructor and Description |
---|
HttpResponseProxy(HttpResponse original,
ConnectionHolder connHolder) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(Header header)
Adds a header to this message.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header to this message.
|
void |
close() |
boolean |
containsHeader(java.lang.String name)
Checks if a certain header is present in this message.
|
Header[] |
getAllHeaders()
Returns all the headers of this message.
|
HttpEntity |
getEntity()
Obtains the message entity of this response, if any.
|
Header |
getFirstHeader(java.lang.String name)
Returns the first header with a specified name of this message.
|
Header[] |
getHeaders(java.lang.String name)
Returns all the headers with a specified name of this message.
|
Header |
getLastHeader(java.lang.String name)
Returns the last header with a specified name of this message.
|
java.util.Locale |
getLocale()
Obtains the locale of this response.
|
HttpParams |
getParams()
Deprecated.
|
ProtocolVersion |
getProtocolVersion()
Returns the protocol version this message is compatible with.
|
StatusLine |
getStatusLine()
Obtains the status line of this response.
|
HeaderIterator |
headerIterator()
Returns an iterator of all the headers.
|
HeaderIterator |
headerIterator(java.lang.String name)
Returns an iterator of the headers with a given name.
|
void |
removeHeader(Header header)
Removes a header from this message.
|
void |
removeHeaders(java.lang.String name)
Removes all headers with a certain name from this message.
|
void |
setEntity(HttpEntity entity)
Associates a response entity with this response.
|
void |
setHeader(Header header)
Overwrites the first header with the same name.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Overwrites the first header with the same name.
|
void |
setHeaders(Header[] headers)
Overwrites all the headers in the message.
|
void |
setLocale(java.util.Locale loc)
Changes the locale of this response.
|
void |
setParams(HttpParams params)
Deprecated.
|
void |
setReasonPhrase(java.lang.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,
java.lang.String reason)
Sets the status line of this response with a reason phrase.
|
void |
setStatusLine(StatusLine statusline)
Sets the status line of this response.
|
java.lang.String |
toString() |
public HttpResponseProxy(HttpResponse original, ConnectionHolder connHolder)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public StatusLine getStatusLine()
HttpResponse
setStatusLine
methods,
or it can be initialized in a constructor.getStatusLine
in interface HttpResponse
null
if not yet setpublic 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, java.lang.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) throws java.lang.IllegalStateException
HttpResponse
setStatusCode
in interface HttpResponse
code
- the HTTP status code.java.lang.IllegalStateException
- if the status line has not be setHttpStatus
,
HttpResponse.setStatusLine(StatusLine)
,
HttpResponse.setStatusLine(ProtocolVersion,int)
public void setReasonPhrase(java.lang.String reason) throws java.lang.IllegalStateException
HttpResponse
setReasonPhrase
in interface HttpResponse
reason
- the new reason phrase as a single-line string, or
null
to unset the reason phrasejava.lang.IllegalStateException
- if the status line has not be setHttpResponse.setStatusLine(StatusLine)
,
HttpResponse.setStatusLine(ProtocolVersion,int)
public HttpEntity getEntity()
HttpResponse
setEntity
.getEntity
in interface HttpResponse
null
if there is nonepublic 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 java.util.Locale getLocale()
HttpResponse
status code
.
It can be changed using setLocale
.getLocale
in interface HttpResponse
null
public void setLocale(java.util.Locale loc)
HttpResponse
setLocale
in interface HttpResponse
loc
- the new localepublic ProtocolVersion getProtocolVersion()
HttpMessage
getProtocolVersion
in interface HttpMessage
public boolean containsHeader(java.lang.String name)
HttpMessage
containsHeader
in interface HttpMessage
name
- the header name to check for.public Header[] getHeaders(java.lang.String name)
HttpMessage
getHeaders
in interface HttpMessage
name
- the name of the headers to return.name
.public Header getFirstHeader(java.lang.String name)
HttpMessage
HttpMessage.getHeaders(String)
is returned.
If there is no matching header in the message null
is
returned.getFirstHeader
in interface HttpMessage
name
- the name of the header to return.name
or null
if no such header could be found.public Header getLastHeader(java.lang.String name)
HttpMessage
HttpMessage.getHeaders(String)
is returned. If there is no
matching header in the message null
is returned.getLastHeader
in interface HttpMessage
name
- the name of the header to return.name
.
or null
if no such header could be found.public Header[] getAllHeaders()
HttpMessage
getAllHeaders
in interface HttpMessage
public void addHeader(Header header)
HttpMessage
addHeader
in interface HttpMessage
header
- the header to append.public void addHeader(java.lang.String name, java.lang.String value)
HttpMessage
addHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header.public void setHeader(Header header)
HttpMessage
setHeader
in interface HttpMessage
header
- the header to set.public void setHeader(java.lang.String name, java.lang.String value)
HttpMessage
setHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header.public void setHeaders(Header[] headers)
HttpMessage
setHeaders
in interface HttpMessage
headers
- the array of headers to set.public void removeHeader(Header header)
HttpMessage
removeHeader
in interface HttpMessage
header
- the header to remove.public void removeHeaders(java.lang.String name)
HttpMessage
removeHeaders
in interface HttpMessage
name
- The name of the headers to remove.public HeaderIterator headerIterator()
HttpMessage
headerIterator
in interface HttpMessage
public HeaderIterator headerIterator(java.lang.String name)
HttpMessage
headerIterator
in interface HttpMessage
name
- the name of the headers over which to iterate, or
null
for all headers@Deprecated public HttpParams getParams()
HttpMessage
HttpMessage.setParams(HttpParams)
.getParams
in interface HttpMessage
@Deprecated public void setParams(HttpParams params)
HttpMessage
setParams
in interface HttpMessage
params
- the parameterspublic java.lang.String toString()
toString
in class java.lang.Object