Skip to content
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

All HttpMessageConverters should support StreamingHttpOutputMessage [SPR-12715] #17312

Closed
spring-issuemaster opened this issue Feb 13, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Feb 13, 2015

John Mark opened SPR-12715 and commented

I would be nice if HttpComponentsClientHttpRequestFactory was able to fully support streaming (non-buffered) requests. Currently, the HttpComponentsStreamingClientHttpRequest class does not support the getBodyInternal() method which prevents it from being used with many MessageConverters.

I would think the HttpComponentsClientHttpRequestFactory should mirror the SimpleClientHttpRequestFactory which does provide full streaming support.


Issue Links:

  • #15825 Error while using HttpComponentsStreamingClientHttpRequest ("is duplicated by")
  • #18480 Regression: BufferedImageHttpMessageConverter does not set content-type header
  • #21650 HttpComponentsStreamingClientHttpRequest fails if restTemplate has interceptors

Referenced from: commits 8ab2e47

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 27, 2015

Arjen Poutsma commented

I'm not entirely sure what you mean with "full streaming". The whole point of the HttpComponentsStreamingClientHttpRequest is that it does do streaming through HTTP Components's HttpEntity interface, so that instead of writing to an internal buffer first, we write directly to the output stream through this interface when the request is executed.

It does work differently than the SimpleClientHttpRequestFactory, which does allow you to write directly to the output stream, either by giving the content-length upfront, or by using chunked mode. However, due to the design of HTTP Components, we cannot simply copy that approach over. Instead, the way to do streaming with HTTP components is to use HttpEntity, AFAIK.

As for the MessageConverters: most converters in Spring extend from the AbstractMessageConverter, which knows how to deal with StreamingHttpOutputMessage instances, see https://github.com/poutsma/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java#L188

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 1, 2015

John Mark commented

Well, the reason that I wrote this ticket was because I was trying to stream a multipart form and I was getting an UnsupportedOperationException. It appears that FormHttpMessageConverter does not implement AbstractMessageConverter and that make it not possible to stream a form using HttpComponentsClientHttpRequestFactory. Perhaps this ticket should be about getting FormHttpMessageConverter (and any others that don't already) to use AbstractMessageConverter.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 2, 2015

Arjen Poutsma commented

Fixed.

PR at #750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.