@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.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic StatusLine getStatusLine()
HttpResponsesetStatusLine methods,
or it can be initialized in a constructor.getStatusLine in interface HttpResponsenull if not yet setpublic void setStatusLine(StatusLine statusline)
HttpResponsesetStatusLine in interface HttpResponsestatusline - the status line of this responsepublic void setStatusLine(ProtocolVersion ver, int code)
HttpResponselocale.setStatusLine in interface HttpResponsever - the HTTP versioncode - the status codepublic void setStatusLine(ProtocolVersion ver, int code, java.lang.String reason)
HttpResponsesetStatusLine in interface HttpResponsever - the HTTP versioncode - the status codereason - the reason phrase, or null to omitpublic void setStatusCode(int code)
throws java.lang.IllegalStateException
HttpResponsesetStatusCode in interface HttpResponsecode - 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
HttpResponsesetReasonPhrase in interface HttpResponsereason - 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()
HttpResponsesetEntity.getEntity in interface HttpResponsenull 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 HttpResponseentity - the entity to associate with this response, or
null to unsetHttpEntity.isStreaming(),
EntityUtils.updateEntity(HttpResponse, HttpEntity)public java.util.Locale getLocale()
HttpResponsestatus code.
It can be changed using setLocale.getLocale in interface HttpResponsenullpublic void setLocale(java.util.Locale loc)
HttpResponsesetLocale in interface HttpResponseloc - the new localepublic ProtocolVersion getProtocolVersion()
HttpMessagegetProtocolVersion in interface HttpMessagepublic boolean containsHeader(java.lang.String name)
HttpMessagecontainsHeader in interface HttpMessagename - the header name to check for.public Header[] getHeaders(java.lang.String name)
HttpMessagegetHeaders in interface HttpMessagename - the name of the headers to return.name.public Header getFirstHeader(java.lang.String name)
HttpMessageHttpMessage.getHeaders(String) is returned.
If there is no matching header in the message null is
returned.getFirstHeader in interface HttpMessagename - the name of the header to return.name
or null if no such header could be found.public Header getLastHeader(java.lang.String name)
HttpMessageHttpMessage.getHeaders(String) is returned. If there is no
matching header in the message null is returned.getLastHeader in interface HttpMessagename - the name of the header to return.name.
or null if no such header could be found.public Header[] getAllHeaders()
HttpMessagegetAllHeaders in interface HttpMessagepublic void addHeader(Header header)
HttpMessageaddHeader in interface HttpMessageheader - the header to append.public void addHeader(java.lang.String name,
java.lang.String value)
HttpMessageaddHeader in interface HttpMessagename - the name of the header.value - the value of the header.public void setHeader(Header header)
HttpMessagesetHeader in interface HttpMessageheader - the header to set.public void setHeader(java.lang.String name,
java.lang.String value)
HttpMessagesetHeader in interface HttpMessagename - the name of the header.value - the value of the header.public void setHeaders(Header[] headers)
HttpMessagesetHeaders in interface HttpMessageheaders - the array of headers to set.public void removeHeader(Header header)
HttpMessageremoveHeader in interface HttpMessageheader - the header to remove.public void removeHeaders(java.lang.String name)
HttpMessageremoveHeaders in interface HttpMessagename - The name of the headers to remove.public HeaderIterator headerIterator()
HttpMessageheaderIterator in interface HttpMessagepublic HeaderIterator headerIterator(java.lang.String name)
HttpMessageheaderIterator in interface HttpMessagename - the name of the headers over which to iterate, or
null for all headers@Deprecated public HttpParams getParams()
HttpMessageHttpMessage.setParams(HttpParams).getParams in interface HttpMessage@Deprecated public void setParams(HttpParams params)
HttpMessagesetParams in interface HttpMessageparams - the parameterspublic java.lang.String toString()
toString in class java.lang.Object