Spring Boot Web - No Content-Length header returned for HEAD response #43272
Labels
for: external-project
For an external project and not something we can fix
status: invalid
An issue that we don't feel is valid
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!!
The text was updated successfully, but these errors were encountered: