diff --git a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java index dd570cc5a2..5149618c7b 100644 --- a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.http.client; import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.util.Iterator; import java.util.List; @@ -92,7 +93,17 @@ class InterceptingClientHttpRequest extends AbstractBufferingClientHttpRequest { request.getHeaders().forEach((key, value) -> delegate.getHeaders().addAll(key, value)); if (body.length > 0) { if (delegate instanceof StreamingHttpOutputMessage streamingOutputMessage) { - streamingOutputMessage.setBody(outputStream -> StreamUtils.copy(body, outputStream)); + streamingOutputMessage.setBody(new StreamingHttpOutputMessage.Body() { + @Override + public void writeTo(OutputStream outputStream) throws IOException { + StreamUtils.copy(body, outputStream); + } + + @Override + public boolean repeatable() { + return true; + } + }); } else { StreamUtils.copy(body, delegate.getBody());