Hi,
When migrating from Spring Boot 3.3.5 to 3.3.6 (or 3.4.0), it seems that the Content-Length is filtered on every HEAD requests.
Here is a minimal example that demonstrates the issue:
@RestController
public class AnyController {
@RequestMapping(method = RequestMethod.HEAD)
public ResponseEntity<Void> getAnyHeader() {
return ResponseEntity.ok().headers(httpHeaders -> httpHeaders.setContentLength(50L)).build();
}
}
I found a related issue reported on Stack Overflow: Content-Length Header is Removed from HEAD Response. Thanks for your help!
Comment From: wilkinsona
Duplicates https://github.com/spring-projects/spring-boot/issues/43272.