class MessageBodyClientHttpResponseWrapper extends java.lang.Object implements ClientHttpResponse
ClientHttpResponse that can not only check if
the response has a message body, but also if its length is 0 (i.e. empty)
by actually reading the input stream.| Modifier and Type | Field and Description |
|---|---|
private java.io.PushbackInputStream |
pushbackInputStream |
private ClientHttpResponse |
response |
| Constructor and Description |
|---|
MessageBodyClientHttpResponseWrapper(ClientHttpResponse response) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this response, freeing any resources created.
|
java.io.InputStream |
getBody()
Return the body of the message as an input stream.
|
HttpHeaders |
getHeaders()
Return the headers of this message.
|
int |
getRawStatusCode()
Return the HTTP status code of the response as integer
|
HttpStatus |
getStatusCode()
Return the HTTP status code of the response.
|
java.lang.String |
getStatusText()
Return the HTTP status text of the response.
|
boolean |
hasEmptyMessageBody()
Indicates whether the response has an empty message body.
|
boolean |
hasMessageBody()
Indicates whether the response has a message body.
|
private final ClientHttpResponse response
private java.io.PushbackInputStream pushbackInputStream
public MessageBodyClientHttpResponseWrapper(ClientHttpResponse response) throws java.io.IOException
java.io.IOExceptionpublic boolean hasMessageBody()
throws java.io.IOException
Implementation returns false for:
1XX, 204 or 304Content-Length header of 0true if the response has a message body, false otherwisejava.io.IOException - in case of I/O errorspublic boolean hasEmptyMessageBody()
throws java.io.IOException
Implementation tries to read the first bytes of the response stream:
true if the response has a zero-length message body, false otherwisejava.io.IOException - in case of I/O errorspublic HttpHeaders getHeaders()
HttpMessagegetHeaders in interface HttpMessagenull)public java.io.InputStream getBody()
throws java.io.IOException
HttpInputMessagegetBody in interface HttpInputMessagenull)java.io.IOException - in case of I/O Errorspublic HttpStatus getStatusCode() throws java.io.IOException
ClientHttpResponsegetStatusCode in interface ClientHttpResponsejava.io.IOException - in case of I/O errorspublic int getRawStatusCode()
throws java.io.IOException
ClientHttpResponsegetRawStatusCode in interface ClientHttpResponsejava.io.IOException - in case of I/O errorspublic java.lang.String getStatusText()
throws java.io.IOException
ClientHttpResponsegetStatusText in interface ClientHttpResponsejava.io.IOException - in case of I/O errorspublic void close()
ClientHttpResponseclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface ClientHttpResponse