Support StreamingHttpOutputMessage in RestClient

This commit allows RestClient to handle StreamingHttpOutputMessage
properly by checking the type of the request and invoking setBody()
when appropriate. This improves interoperability with components that
expect streamed output.

A new integration test has been added to verify the functionality.

See gh-35102

Signed-off-by: Daniil Razorenov <daniltmb@gmail.com>
This commit is contained in:
Daniil Razorenov
2025-06-23 22:54:28 +05:00
committed by rstoyanchev
parent 2477544a8f
commit 8d6117e419
2 changed files with 30 additions and 1 deletions
@@ -466,7 +466,14 @@ final class DefaultRestClient implements RestClient {
@Override
public RequestBodySpec body(StreamingHttpOutputMessage.Body body) {
this.body = request -> body.writeTo(request.getBody());
this.body = request -> {
if (request instanceof StreamingHttpOutputMessage streamingMessage) {
streamingMessage.setBody(body);
}
else {
body.writeTo(request.getBody());
}
};
return this;
}