Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Web - No Content-Length header returned for HEAD response #43272

Closed
blulic opened this issue Nov 22, 2024 · 2 comments
Closed

Spring Boot Web - No Content-Length header returned for HEAD response #43272

blulic opened this issue Nov 22, 2024 · 2 comments
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

Comments

@blulic
Copy link

blulic commented Nov 22, 2024

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!!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2024
@bclozel
Copy link
Member

bclozel commented Nov 22, 2024

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

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 22, 2024
@blulic
Copy link
Author

blulic commented Nov 22, 2024

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.

jenkins-daemon pushed a commit to hortonworks/cloudbreak that referenced this issue Dec 11, 2024
…omcat, and after fixing it in a former commit, it turned out that the org.apache.tomcat.embed:tomcat-embed-el is a transitive dependency of spring boot, so we shall update it as well.

It turned out that Tomcat has also introduced a bug and for a few version it did not send back the content length for HTTP HEAD, therefore Tomcat version had to be upgraded, othervise the image catalog content validation would just fail: spring-projects/spring-boot#43272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants