Closed as not planned
Description
The OkHttp3ClientHttpRequestFactory caches the request body. When the request body is too large, an OOM occurs.
The RestTemplate is:
OkHttp3ClientHttpRequestFactory factory =
new OkHttp3ClientHttpRequestFactory(new OkHttpClient());
RestTemplate restTemplate = new RestTemplate(factory);
But when i user OkHttp3Clientto upload this file, it is successful.
My question is why the SimpleClientHttpRequestFactory can set bufferRequestBody?
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
HttpURLConnection connection = openConnection(uri.toURL(), this.proxy);
prepareConnection(connection, httpMethod.name());
if (this.bufferRequestBody) {
return new SimpleBufferingClientHttpRequest(connection, this.outputStreaming);
}
else {
return new SimpleStreamingClientHttpRequest(connection, this.chunkSize, this.outputStreaming);
}
}
but OkHttp3ClientHttpRequestFactory without this switch?
I want to use the OkHttp3ClientHttpRequestFactory object without caching the request body,How can I do it?