org.springframework.http.client
Class BufferingClientHttpResponseWrapper

java.lang.Object
  extended by org.springframework.http.client.BufferingClientHttpResponseWrapper
All Implemented Interfaces:
ClientHttpResponse, HttpInputMessage, HttpMessage

final class BufferingClientHttpResponseWrapper
extends java.lang.Object
implements ClientHttpResponse

Simple implementation of ClientHttpResponse that reads the request's body into memory, thus allowing for multiple invocations of getBody().

Since:
3.1
Author:
Arjen Poutsma

Field Summary
private  byte[] body
           
private  ClientHttpResponse response
           
 
Constructor Summary
BufferingClientHttpResponseWrapper(ClientHttpResponse response)
           
 
Method Summary
 void close()
          Closes 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.
 HttpStatus getStatusCode()
          Return the HTTP status code of the response.
 java.lang.String getStatusText()
          Return the HTTP status text of the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

response

private final ClientHttpResponse response

body

private byte[] body
Constructor Detail

BufferingClientHttpResponseWrapper

BufferingClientHttpResponseWrapper(ClientHttpResponse response)
Method Detail

getStatusCode

public HttpStatus getStatusCode()
                         throws java.io.IOException
Description copied from interface: ClientHttpResponse
Return the HTTP status code of the response.

Specified by:
getStatusCode in interface ClientHttpResponse
Returns:
the HTTP status as an HttpStatus enum value
Throws:
java.io.IOException - in case of I/O errors

getStatusText

public java.lang.String getStatusText()
                               throws java.io.IOException
Description copied from interface: ClientHttpResponse
Return the HTTP status text of the response.

Specified by:
getStatusText in interface ClientHttpResponse
Returns:
the HTTP status text
Throws:
java.io.IOException - in case of I/O errors

getHeaders

public HttpHeaders getHeaders()
Description copied from interface: HttpMessage
Return the headers of this message.

Specified by:
getHeaders in interface HttpMessage
Returns:
a corresponding HttpHeaders object

getBody

public java.io.InputStream getBody()
                            throws java.io.IOException
Description copied from interface: HttpInputMessage
Return the body of the message as an input stream.

Specified by:
getBody in interface HttpInputMessage
Returns:
the input stream body
Throws:
java.io.IOException - in case of I/O Errors

close

public void close()
Description copied from interface: ClientHttpResponse
Closes this response, freeing any resources created.

Specified by:
close in interface ClientHttpResponse