Top Description Fields Constructors Methods
org.apache.http.impl.execchain

pack-priv Class HttpResponseProxy

extends Object
implements CloseableHttpResponse
Class Inheritance
All Implemented Interfaces
org.apache.http.client.methods.CloseableHttpResponse, java.io.Closeable, java.lang.AutoCloseable, org.apache.http.HttpResponse, org.apache.http.HttpMessage
Imports
java.io.IOException, java.util.Locale, org.apache.http.Header, .HeaderIterator, .HttpEntity, .HttpResponse, .ProtocolVersion, .StatusLine, org.apache.http.client.methods.CloseableHttpResponse, org.apache.http.params.HttpParams

A proxy class for org.apache.http.HttpResponse that can be used to release client connection associated with the original response.
Since
4.3

Field Summary

Modifier and TypeField and Description
private final ConnectionHolder
private final HttpResponse

Constructor Summary

AccessConstructor and Description
public
HttpResponseProxy(final HttpResponse original, final ConnectionHolder connHolder)

Method Summary

Modifier and TypeMethod and Description
public void
addHeader(final Header
the header to append.
header
)

Implements org.apache.http.HttpMessage.addHeader.

Adds a header to this message.
public void
addHeader(final String
the name of the header.
name
,
final String
the value of the header.
value
)

Implements org.apache.http.HttpMessage.addHeader.

Adds a header to this message.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public boolean
containsHeader(final String
the header name to check for.
name
)

Implements org.apache.http.HttpMessage.containsHeader.

Checks if a certain header is present in this message.
public Header[]
getAllHeaders()

Implements org.apache.http.HttpMessage.getAllHeaders.

Returns all the headers of this message.
public HttpEntity
getEntity()

Implements org.apache.http.HttpResponse.getEntity.

Obtains the message entity of this response, if any.
public Header
getFirstHeader(final String
the name of the header to return.
name
)

Implements org.apache.http.HttpMessage.getFirstHeader.

Returns the first header with a specified name of this message.
public Header[]
getHeaders(final String
the name of the headers to return.
name
)

Implements org.apache.http.HttpMessage.getHeaders.

Returns all the headers with a specified name of this message.
public Header
getLastHeader(final String
the name of the header to return.
name
)

Implements org.apache.http.HttpMessage.getLastHeader.

Returns the last header with a specified name of this message.
public Locale
getLocale()

Implements org.apache.http.HttpResponse.getLocale.

Obtains the locale of this response.
public HttpParams
getParams()

Implements org.apache.http.HttpMessage.getParams.

Deprecated as a consequence of HttpParams being deprecated.
Returns the parameters effective for this message as set by setParams(HttpParams).
public ProtocolVersion
getProtocolVersion()

Implements org.apache.http.HttpMessage.getProtocolVersion.

Returns the protocol version this message is compatible with.
public StatusLine
getStatusLine()

Implements org.apache.http.HttpResponse.getStatusLine.

Obtains the status line of this response.
public HeaderIterator
headerIterator()

Implements org.apache.http.HttpMessage.headerIterator.

Returns an iterator of all the headers.
public HeaderIterator
headerIterator(final String
the name of the headers over which to iterate, or null for all headers
name
)

Implements org.apache.http.HttpMessage.headerIterator.

Returns an iterator of the headers with a given name.
public void
removeHeader(final Header
the header to remove.
header
)

Implements org.apache.http.HttpMessage.removeHeader.

Removes a header from this message.
public void
removeHeaders(final String
The name of the headers to remove.
name
)

Implements org.apache.http.HttpMessage.removeHeaders.

Removes all headers with a certain name from this message.
public void
setEntity(final HttpEntity
the entity to associate with this response, or null to unset
entity
)

Implements org.apache.http.HttpResponse.setEntity.

Associates a response entity with this response.
public void
setHeader(final Header
the header to set.
header
)

Implements org.apache.http.HttpMessage.setHeader.

Overwrites the first header with the same name.
public void
setHeader(final String
the name of the header.
name
,
final String
the value of the header.
value
)

Implements org.apache.http.HttpMessage.setHeader.

Overwrites the first header with the same name.
public void
setHeaders(final Header[]
the array of headers to set.
headers
)

Implements org.apache.http.HttpMessage.setHeaders.

Overwrites all the headers in the message.
public void
setLocale(final Locale
the new locale
loc
)

Implements org.apache.http.HttpResponse.setLocale.

Changes the locale of this response.
public void
setParams(final HttpParams
the parameters
params
)

Implements org.apache.http.HttpMessage.setParams.

Deprecated as a consequence of HttpParams being deprecated.
Provides parameters to be used for the processing of this message.
public void
setReasonPhrase(final String
the new reason phrase as a single-line string, or null to unset the reason phrase
reason
)

Implements org.apache.http.HttpResponse.setReasonPhrase.

Updates the status line of this response with a new reason phrase.
public void
setStatusCode(final int
the HTTP status code.
code
)

Implements org.apache.http.HttpResponse.setStatusCode.

Updates the status line of this response with a new status code.
public void
setStatusLine(final StatusLine
the status line of this response
statusline
)

Implements org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response.
public void
setStatusLine(final ProtocolVersion
the HTTP version
ver
,
final int
the status code
code
)

Implements org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response.
public void
setStatusLine(final ProtocolVersion
the HTTP version
ver
,
final int
the status code
code
,
final String
the reason phrase, or null to omit
reason
)

Implements org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response with a reason phrase.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

connHolderback to summary
private final ConnectionHolder connHolder
originalback to summary
private final HttpResponse original

Constructor Detail

HttpResponseProxyback to summary
public HttpResponseProxy(final HttpResponse original, final ConnectionHolder connHolder)

Method Detail

addHeaderback to summary
public void addHeader(final Header header)

Implements org.apache.http.HttpMessage.addHeader.

Doc from org.apache.http.HttpMessage.addHeader.

Adds a header to this message. The header will be appended to the end of the list.

Parameters
header:Header

the header to append.

Annotations
@Override
addHeaderback to summary
public void addHeader(final String name, final String value)

Implements org.apache.http.HttpMessage.addHeader.

Doc from org.apache.http.HttpMessage.addHeader.

Adds a header to this message. The header will be appended to the end of the list.

Parameters
name:String

the name of the header.

value:String

the value of the header.

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
containsHeaderback to summary
public boolean containsHeader(final String name)

Implements org.apache.http.HttpMessage.containsHeader.

Doc from org.apache.http.HttpMessage.containsHeader.

Checks if a certain header is present in this message. Header values are ignored.

Parameters
name:String

the header name to check for.

Returns:boolean

true if at least one header with this name is present.

Annotations
@Override
getAllHeadersback to summary
public Header[] getAllHeaders()

Implements org.apache.http.HttpMessage.getAllHeaders.

Doc from org.apache.http.HttpMessage.getAllHeaders.

Returns all the headers of this message. Headers are orderd in the sequence they will be sent over a connection.

Returns:Header[]

all the headers of this message

Annotations
@Override
getEntityback to summary
public HttpEntity getEntity()

Implements org.apache.http.HttpResponse.getEntity.

Doc from org.apache.http.HttpResponse.getEntity.

Obtains the message entity of this response, if any. The entity is provided by calling setEntity.

Returns:HttpEntity

the response entity, or null if there is none

Annotations
@Override
getFirstHeaderback to summary
public Header getFirstHeader(final String name)

Implements org.apache.http.HttpMessage.getFirstHeader.

Doc from org.apache.http.HttpMessage.getFirstHeader.

Returns the first header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the first element of getHeaders(String) is returned. If there is no matching header in the message null is returned.

Parameters
name:String

the name of the header to return.

Returns:Header

the first header whose name property equals name or null if no such header could be found.

Annotations
@Override
getHeadersback to summary
public Header[] getHeaders(final String name)

Implements org.apache.http.HttpMessage.getHeaders.

Doc from org.apache.http.HttpMessage.getHeaders.

Returns all the headers with a specified name of this message. Header values are ignored. Headers are orderd in the sequence they will be sent over a connection.

Parameters
name:String

the name of the headers to return.

Returns:Header[]

the headers whose name property equals name.

Annotations
@Override
getLastHeaderback to summary
public Header getLastHeader(final String name)

Implements org.apache.http.HttpMessage.getLastHeader.

Doc from org.apache.http.HttpMessage.getLastHeader.

Returns the last header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the last element of getHeaders(String) is returned. If there is no matching header in the message null is returned.

Parameters
name:String

the name of the header to return.

Returns:Header

the last header whose name property equals name. or null if no such header could be found.

Annotations
@Override
getLocaleback to summary
public Locale getLocale()

Implements org.apache.http.HttpResponse.getLocale.

Doc from org.apache.http.HttpResponse.getLocale.

Obtains the locale of this response. The locale is used to determine the reason phrase for the status code. It can be changed using setLocale.

Returns:Locale

the locale of this response, never null

Annotations
@Override
getParamsback to summary
public HttpParams getParams()

Implements org.apache.http.HttpMessage.getParams.

Doc from org.apache.http.HttpMessage.getParams.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Returns the parameters effective for this message as set by setParams(HttpParams).

Annotations
@Override
getProtocolVersionback to summary
public ProtocolVersion getProtocolVersion()

Implements org.apache.http.HttpMessage.getProtocolVersion.

Doc from org.apache.http.HttpMessage.getProtocolVersion.

Returns the protocol version this message is compatible with.

Annotations
@Override
getStatusLineback to summary
public StatusLine getStatusLine()

Implements org.apache.http.HttpResponse.getStatusLine.

Doc from org.apache.http.HttpResponse.getStatusLine.

Obtains the status line of this response. The status line can be set using one of the setStatusLine methods, or it can be initialized in a constructor.

Returns:StatusLine

the status line, or null if not yet set

Annotations
@Override
headerIteratorback to summary
public HeaderIterator headerIterator()

Implements org.apache.http.HttpMessage.headerIterator.

Doc from org.apache.http.HttpMessage.headerIterator.

Returns an iterator of all the headers.

Returns:HeaderIterator

Iterator that returns Header objects in the sequence they are sent over a connection.

Annotations
@Override
headerIteratorback to summary
public HeaderIterator headerIterator(final String name)

Implements org.apache.http.HttpMessage.headerIterator.

Doc from org.apache.http.HttpMessage.headerIterator.

Returns an iterator of the headers with a given name.

Parameters
name:String

the name of the headers over which to iterate, or null for all headers

Returns:HeaderIterator

Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.

Annotations
@Override
removeHeaderback to summary
public void removeHeader(final Header header)

Implements org.apache.http.HttpMessage.removeHeader.

Doc from org.apache.http.HttpMessage.removeHeader.

Removes a header from this message.

Parameters
header:Header

the header to remove.

Annotations
@Override
removeHeadersback to summary
public void removeHeaders(final String name)

Implements org.apache.http.HttpMessage.removeHeaders.

Doc from org.apache.http.HttpMessage.removeHeaders.

Removes all headers with a certain name from this message.

Parameters
name:String

The name of the headers to remove.

Annotations
@Override
setEntityback to summary
public void setEntity(final HttpEntity entity)

Implements org.apache.http.HttpResponse.setEntity.

Doc from org.apache.http.HttpResponse.setEntity.

Associates a response entity with this response.

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.

Parameters
entity:HttpEntity

the entity to associate with this response, or null to unset

Annotations
@Override
setHeaderback to summary
public void setHeader(final Header header)

Implements org.apache.http.HttpMessage.setHeader.

Doc from org.apache.http.HttpMessage.setHeader.

Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.

Parameters
header:Header

the header to set.

Annotations
@Override
setHeaderback to summary
public void setHeader(final String name, final String value)

Implements org.apache.http.HttpMessage.setHeader.

Doc from org.apache.http.HttpMessage.setHeader.

Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.

Parameters
name:String

the name of the header.

value:String

the value of the header.

Annotations
@Override
setHeadersback to summary
public void setHeaders(final Header[] headers)

Implements org.apache.http.HttpMessage.setHeaders.

Doc from org.apache.http.HttpMessage.setHeaders.

Overwrites all the headers in the message.

Parameters
headers:Header[]

the array of headers to set.

Annotations
@Override
setLocaleback to summary
public void setLocale(final Locale loc)

Implements org.apache.http.HttpResponse.setLocale.

Doc from org.apache.http.HttpResponse.setLocale.

Changes the locale of this response.

Parameters
loc:Locale

the new locale

Annotations
@Override
setParamsback to summary
public void setParams(final HttpParams params)

Implements org.apache.http.HttpMessage.setParams.

Doc from org.apache.http.HttpMessage.setParams.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Provides parameters to be used for the processing of this message.

Parameters
params:HttpParams

the parameters

Annotations
@Override
setReasonPhraseback to summary
public void setReasonPhrase(final String reason) throws IllegalStateException

Implements org.apache.http.HttpResponse.setReasonPhrase.

Doc from org.apache.http.HttpResponse.setReasonPhrase.

Updates the status line of this response with a new reason phrase.

Parameters
reason:String

the new reason phrase as a single-line string, or null to unset the reason phrase

Annotations
@Override
Exceptions
IllegalStateException:
if the status line has not be set
setStatusCodeback to summary
public void setStatusCode(final int code) throws IllegalStateException

Implements org.apache.http.HttpResponse.setStatusCode.

Doc from org.apache.http.HttpResponse.setStatusCode.

Updates the status line of this response with a new status code.

Parameters
code:int

the HTTP status code.

Annotations
@Override
Exceptions
IllegalStateException:
if the status line has not be set
setStatusLineback to summary
public void setStatusLine(final StatusLine statusline)

Implements org.apache.http.HttpResponse.setStatusLine.

Doc from org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response.

Parameters
statusline:StatusLine

the status line of this response

Annotations
@Override
setStatusLineback to summary
public void setStatusLine(final ProtocolVersion ver, final int code)

Implements org.apache.http.HttpResponse.setStatusLine.

Doc from org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response. The reason phrase will be determined based on the current locale.

Parameters
ver:ProtocolVersion

the HTTP version

code:int

the status code

Annotations
@Override
setStatusLineback to summary
public void setStatusLine(final ProtocolVersion ver, final int code, final String reason)

Implements org.apache.http.HttpResponse.setStatusLine.

Doc from org.apache.http.HttpResponse.setStatusLine.

Sets the status line of this response with a reason phrase.

Parameters
ver:ProtocolVersion

the HTTP version

code:int

the status code

reason:String

the reason phrase, or null to omit

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override