Skip to content

Netty4ClientHttpRequestFactory buffers (aggregates) all requests/responses [SPR-12631] #17232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jan 14, 2015 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 14, 2015

Francisco Lozano opened SPR-12631 and commented

The usage of HttpObjectAggregator is convenient for a quick implementation, but it makes it unfeasible to handle big uploads/downloads.

A streaming-friendly solution would be very useful for handling big requests.


Affects: 4.1.4

Issue Links:

0 votes, 6 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 12, 2016

Brian Clozel commented

After discussing this issue with the team, we've decided to resolve this issue as "won't fix".

First, the HttpObjectAggregator is not just tailored for quick implementations, but is fairly used in many netty-driven HTTP clients out there. By using this, we're indeed buffering the whole request/response in memory.

You're right though, I've seen netty-driven HTTP clients also adopt streaming use cases; they're using dedicated types and methods on their public facing API and a different set of Netty handlers.

We could in theory support the streaming use case on the request side at least, with a streaming variant of our request implementation for Netty. But the overall design of our RestTemplate support (and RestTemplate itself) is a bit at odds with the way things are designed in Netty.

For example, we don't currently support persistent connections with the Netty client (we're closing the connection for each request/response exchange; i.e. not reusing them).

For now, we think that the changes required to improve the support are far from trivial and we'd rather rely on the existing streaming support already available through other implementations.

Note that, as mentioned in #19448, RestTemplate is not meant to provide users with the streaming response. So the streaming response use case isn't supported in any other implementation. Of course, you can still write your own HttpMessageConverter or ResponseExtractor implementation to work with the live response within a RestTemplate call.

If you'd like to look into an HTTP client that supports streaming both ways, you can give a try to the new WebClient (see reference doc here) - to be released with Spring 5.

Thanks!

@spring-projects-issues
Copy link
Collaborator Author

Francisco Lozano commented

If you are covering this functionality in a newer API, I agree it's perfectly reasonable not to fix this in RestTemplate.

When I said 'quick' I didn't mean it as a bad thing, I think it's good to use HttpObjectAggregator, as long as you know the payload sizes and are comfortable with having them fully allocated in memory.

Thanks for giving it thoughtful consideration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants