This issue occured at work when used a spring application as a proxy and returned ResponseEntity received from another service. The received JSON was parsed into a DTO which lacked a property, resulting in the written JSON to be missing a property and those miss bytes. However the content-length header was not updated to reflect the new size of the body. This is also the case if I manually construct a ResponseEntity as shown in the repo. The repo was freshly initialized with spring-boot-starter-parent 3.3.2

Replication Repository

This bug then causes the client side to hang as it waits on the missing bytes. Different clients handle this differently, the Intellij client aborts the request after 60 seconds and displays a failure. While Postman receives the full response, shows that it's a 200 OK but still waits for the missing bytes but doesn't fail after 60 seconds

The fix seems to be to always recalculate the Content-Length header even if already present

Comment From: wilkinsona

Your proxy is at fault here. It should either create and return a new ResponseEntity with a fresh set of HTTP headers, or it should clear the Content-Length header (and any others that are not generally applicable) from the existing ResponseEntity before returning it.

This is also the case if I manually construct a ResponseEntity as shown in the repo

This is to be expected. You've manually set the Content-Length header, so the default Content-Length header is not set.