This is the regression caused by the Spring Boot 3.3.6 upgrade, and it was previously working fine in all prior Spring Boot 3.3 versions, Spring Boot 2.7.x and lower.

Short description: From Spring Boot 3.3.6, web (Spring MVC) application doesn't return the Content-Length response header for the HEAD request.

When requesting HEAD from web application on Spring Boot 3.3.5, it returned the Content-Length header, which is useful if implementation wants to identify the current content size bytes without fetching the actual content (e.g. to fetch a subset of the log file - from the byte range x to y).

From Spring Boot 3.3.6 web applications do not return the Content-Length header. Tested with the media types text/plain and application/octet-stream.

Spring Boot 3.3.5 behaviour:

curl -i localhost:9080/text -X HEAD
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the 
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 200 
Content-Type: text/plain;charset=UTF-8
Content-Length: 1694
Date: Fri, 22 Nov 2024 21:07:38 GMT

Spring Boot 3.3.6 behaviour:

Warning: Setting custom HTTP method to HEAD with -X/--request may not work the 
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 200 
Content-Type: text/plain;charset=UTF-8
Date: Fri, 22 Nov 2024 21:06:38 GMT

I have created a minimum reproducible example in this repository: https://github.com/blulic/sb-bugreport-contentlength Please see associated TextControllerIntegrationTest which is failing on 3.3.6 but passing on 3.3.5.

Note: Issue was initially found on the Spring Boot Actuator Logfile endpoint, but it happens when serving anything plaintext or octet-stream.

Thanks!!

Comment From: bclozel

Thanks for getting in touch. I think this is a Tomcat issue and it's been reported and fixed already: https://bz.apache.org/bugzilla/show_bug.cgi?id=69466

Comment From: blulic

Thanks a lot for the super quick response @bclozel, I will re-test with the Tomcat 10.1.34 whenever it becomes available via maven repo.