Skip to content

The OkHttp3ClientHttpRequestFactory caches the request body. When the request body is too large, an OOM occurs. #28535

Closed as not planned
@DInTheName

Description

@DInTheName

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions