|
|
|
@ -64,35 +64,25 @@ abstract class AbstractBufferingClientHttpRequest extends AbstractClientHttpRequ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Execute with the given request and body. |
|
|
|
* Execute with the given request and body. |
|
|
|
* @param request the request to execute with |
|
|
|
* @param request the request to execute with |
|
|
|
* @param body the body to send |
|
|
|
* @param bufferedOutput the body to write |
|
|
|
* @param bufferResponse whether to buffer the response |
|
|
|
* @param bufferResponse whether to buffer the response |
|
|
|
* @return the resulting response |
|
|
|
* @return the resulting response |
|
|
|
* @throws IOException in case of I/O errors from execution |
|
|
|
* @throws IOException in case of I/O errors from execution |
|
|
|
* @since 7.0 |
|
|
|
* @since 7.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected ClientHttpResponse executeWithRequest( |
|
|
|
protected ClientHttpResponse executeWithRequest( |
|
|
|
ClientHttpRequest request, byte[] body, boolean bufferResponse) throws IOException { |
|
|
|
ClientHttpRequest request, byte[] bufferedOutput, boolean bufferResponse) throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (body.length > 0) { |
|
|
|
if (bufferedOutput.length > 0) { |
|
|
|
long contentLength = request.getHeaders().getContentLength(); |
|
|
|
long contentLength = request.getHeaders().getContentLength(); |
|
|
|
if (contentLength > -1 && contentLength != body.length) { |
|
|
|
if (contentLength > -1 && contentLength != bufferedOutput.length) { |
|
|
|
request.getHeaders().setContentLength(body.length); |
|
|
|
request.getHeaders().setContentLength(bufferedOutput.length); |
|
|
|
} |
|
|
|
} |
|
|
|
if (request instanceof StreamingHttpOutputMessage streamingOutputMessage) { |
|
|
|
if (request instanceof StreamingHttpOutputMessage streamingOutputMessage) { |
|
|
|
streamingOutputMessage.setBody(new StreamingHttpOutputMessage.Body() { |
|
|
|
streamingOutputMessage.setBody(bufferedOutput); |
|
|
|
@Override |
|
|
|
|
|
|
|
public void writeTo(OutputStream outputStream) throws IOException { |
|
|
|
|
|
|
|
StreamUtils.copy(body, outputStream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean repeatable() { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
StreamUtils.copy(body, request.getBody()); |
|
|
|
StreamUtils.copy(bufferedOutput, request.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|