Skip to content

Commit dedf3d7

Browse files
committed
Fix response body caching for async requests
Removes premature body retrieval when content size is greater than zero, ensuring body is only retrieved after async completion. This prevents potential issues with incomplete response bodies in asynchronous scenarios.
1 parent 37cb789 commit dedf3d7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

spring-web-captor/src/main/java/com/davidrandoll/spring_web_captor/publisher/response/CachedBodyHttpServletResponse.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ public CompletableFuture<byte[]> getResponseBody() throws IOException {
3838

3939
this.responseBodyFuture = new CompletableFuture<>();
4040

41-
if (this.getContentSize() > 0) {
42-
getBody(responseBodyFuture);
43-
} else if (request.isAsyncStarted()) {
41+
if (request.isAsyncStarted()) {
4442
request.getAsyncContext().addListener(new AsyncListener() {
4543
public void onComplete(AsyncEvent asyncEvent) throws IOException {
4644
getBody(responseBodyFuture);

0 commit comments

Comments
 (0)