Skip to content

RestTemplate should support streaming download and upload [SPR-16885] #21424

Closed
@spring-projects-issues

Description

@spring-projects-issues

Abhijit Sarkar opened SPR-16885 and commented

ResourceHttpMessageConverter has a boolean supportsReadStreaming, which if set, and the response type is InputStreamResource, returns InputStreamResource; otherwise it returns a ByteArrayResource. So clearly, the intent is supporting streaming download.

However, there is a problem: RestTemplate closes the response soon after the HttpMessageConverter runs. Thus, even if I asked for InputStreamResource, and got it, it's no good, because the response stream has been closed. I think it should be dependent on the response type.

On the writing side, implementations of ClientHttpRequestFactory has a boolean bufferRequestBody but SimpleClientHttpRequestFactory (JDK client) and HttpComponentsClientHttpRequestFactory (Apache HTTP client) support this feature, but not OkHttp3ClientHttpRequestFactory.


Affects: 5.0.2

Reference URL: https://stackoverflow.com/a/48041200/839733

Issue Links:

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions