@Immutable public class SizeLimitedHttpResponseReader extends Object implements HttpResponseReader
| Modifier and Type | Class and Description |
|---|---|
static class |
SizeLimitedHttpResponseReader.ResponseSizeLimitExceededException |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE |
| Constructor and Description |
|---|
SizeLimitedHttpResponseReader(int maxBodySize)
Construct with a
default buffer size. |
SizeLimitedHttpResponseReader(int maxBodySize,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
InMemoryClientHttpResponse |
readResponse(org.springframework.http.client.ClientHttpResponse response)
Reads the original
ClientHttpResponse to memory, if possible,
and returns a serializable copy. |
public static final int DEFAULT_BUFFER_SIZE
public SizeLimitedHttpResponseReader(int maxBodySize)
default buffer size.maxBodySize - The maximal size to read in bytes. It must be
greater then zero and should be multiple of the
DEFAULT_BUFFER_SIZE.public SizeLimitedHttpResponseReader(int maxBodySize,
int bufferSize)
maxBodySize - The maximal size to read in bytes. It must be
greater then zero and should be multiple of the
bufferSize.bufferSize - The buffer size in bytes. It must be greater then zero.public InMemoryClientHttpResponse readResponse(org.springframework.http.client.ClientHttpResponse response) throws SizeLimitedHttpResponseReader.ResponseSizeLimitExceededException, IOException
ClientHttpResponse to memory, if possible,
and returns a serializable copy. If the response's body size exceeds the
specified maxBodySize limit, then it throws
SizeLimitedHttpResponseReader.ResponseSizeLimitExceededException with a reconstructed response
that combines an already read bytes in memory and the original response.readResponse in interface HttpResponseReaderresponse - The original response to read.SizeLimitedHttpResponseReader.ResponseSizeLimitExceededException - When the response's body size
exceeds the specified maxBodySize limit.IOExceptionCopyright © 2014. All rights reserved.