Skip to content

Make it easier to get InputStream from RestClient #36380

@rstoyanchev

Description

@rstoyanchev

In #32358 we added support to get InputStream through an HTTP Service interface. This involved detecting a return type of InputStream in RestClientAdapter, calling exchange with close=false, and returning (i.e. bypassing message converters).

We can push this further down into RestClient so it falls back on returning the InputStream of the response if no suitable message converter is found, and keeping the response open if the return value suggests it is yet to be consumed, e.g. InputStream or InputStreamResource.

The rational is the same as that of #32358, but making it built in RestClient, and requiring no special code in RestClientAdapter, also helping #36374. It will remove the surprise from using .retrieve(InputStreamResource.class) and having the response closed.

The alternative today is to call exchange and consume the response.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions