You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent support for RequestCallback in HttpComponentsClientHttpRequestFactory [SPR-11981] #16597
in: webIssues in web modules (web, webmvc, webflux, websocket)status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process
HttpComponentsClientHttpRequestFactory is supposed to handle features in a similar manner as SimpleClientHttpRequestFactory but it does not support RequestCallback when the bufferRequestBody is disabled.
Consider the following code
// Create the HttpComponentsClientHttpRequestFactorySimpleClientHttpRequestFactorypreconfiguredHTTPInstance = newSimpleClientHttpRequestFactory();
// Set BufferRequestBody as false, default is true.preconfiguredHTTPInstance.setBufferRequestBody(false);
RestTemplaterestTemplate = newRestTemplate();
restTemplate.setRequestFactory(preconfiguredHTTPInstance);
restTemplate.getMessageConverters().add(newStringHttpMessageConverter());
RequestCallbackrequestCallback = newRequestCallback() {
@OverridepublicvoiddoWithRequest(ClientHttpRequestrequest) throwsIOException {
IOUtils.copy(content.getInputStream(), request.getBody());
}
};
HttpMessageConverterExtractor<String> responseExtractor =
newHttpMessageConverterExtractor<String>(String.class, restTemplate.getMessageConverters());
returnrestTemplate.execute(url, HttpMethod.POST, requestCallback, responseExtractor)
Switching to HttpComponentsClientHttpRequestFactory leads to UnsupportedOperationException("getBody not supported")
I sended pull request about this issue.
The problem is that Spring users don't know difference between HttpComponentsClientHttpRequestFactory and SimpleClientHttpRequestFactory.
So I created testcase about HttpComponentsClientHttpRequestFactory test if bufferRequestBody is false.
Here is the pull request : #603
in: webIssues in web modules (web, webmvc, webflux, websocket)status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process
Activity
spring-projects-issues commentedon Jul 28, 2014
hangsub lim commented
Is there any reason to throw Exception below?
@Overrideprotected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
throw new UnsupportedOperationException("getBody not supported");
}
spring-projects-issues commentedon Jul 28, 2014
Stéphane Nicoll commented
Yes. That's the way HttpComponents work and this issue is about explaining that in the documentation.
spring-projects-issues commentedon Aug 26, 2014
hangsub lim commented
I sended pull request about this issue.
The problem is that Spring users don't know difference between HttpComponentsClientHttpRequestFactory and SimpleClientHttpRequestFactory.
So I created testcase about HttpComponentsClientHttpRequestFactory test if bufferRequestBody is false.
Here is the pull request : #603
spring-projects-issues commentedon Jan 12, 2019
Bulk closing outdated, unresolved issues. Please, reopen if still relevant.