Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. spring-projects-issues commented on Dec 12, 2016

    @spring-projects-issues
    CollaboratorAuthor

    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!

  2. spring-projects-issues commented on Dec 13, 2016

    @spring-projects-issues
    CollaboratorAuthor

    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!

  3. added
    status: declined
    type: enhancement
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webstatus: declinedtype: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions