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

Error while using HttpComponentsStreamingClientHttpRequest [SPR-11199] #15825

Closed
spring-issuemaster opened this issue Dec 9, 2013 · 2 comments

Comments

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

commented Dec 9, 2013

Kaustubh Keshav opened SPR-11199 and commented

I was testing and trying to use the streaming http request via the http components. But I get the below error.

Sample code I used for initialization -

RestTemplate restTemplate = new RestTemplate();
HttpComponentsClientHttpRequestFactory aConnFactory = new HttpComponentsClientHttpRequestFactory();
        aConnFactory.setHttpClient(HttpClientBuilder.create().disableAutomaticRetries().setMaxConnTotal(10).setMaxConnPerRoute(3).build());
        aConnFactory.setBufferRequestBody(false);

        restTemplate.setRequestFactory(aConnFactory);
        List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();

        MappingJackson2HttpMessageConverter aConverter = new MappingJackson2HttpMessageConverter();
FormHttpMessageConverter aHttpMessageConverter = new FormHttpMessageConverter();
messageConverters.add(aConverter);
        messageConverters.add(aHttpMessageConverter);
restTemplate.setMessageConverters(messageConverters);

Error -

'getBody not supported when bufferRequestBody is false'
	at org.springframework.http.client.HttpComponentsStreamingClientHttpRequest.getBodyInternal(HttpComponentsStreamingClientHttpRequest.java:85)
	at org.springframework.http.client.AbstractClientHttpRequest.getBody(AbstractClientHttpRequest.java:46)
	at org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:264)
	at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:204)
	at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:72)
	at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:739)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:525)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:504)
	at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:360)

Affects: 4.0 RC2

Reference URL: #312

Issue Links:

  • #17312 All HttpMessageConverters should support StreamingHttpOutputMessage ("duplicates")

2 votes, 4 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 25, 2015

Brian Clozel commented

A fix for this has been pushed by Arjen Poutsma in #17312.
This is already available in 4.2.0.RC1 - feel free to confirm this fix!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 25, 2015

Nikita Shmakov commented

Seems this fix works! Thank you!

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.