-
Notifications
You must be signed in to change notification settings - Fork 38.5k
HEAD response has "Content-Length: 0" for @RestController @GetMapping methods [SPR-15261] #19826
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
Comments
David Goblirsch commented I forgot to mention that I am using the "ShallowEtagHeaderFilter" to automatically get ETag and Content-Length headers in my responses. |
David Goblirsch commented Indeed, when I remove the use of the ShallowEtagHeaderFilter I no longer get an ETag header (nor a Content-Length for GET) but I now get |
Brian Clozel commented
Responses to What do you think David Goblirsch? |
Juergen Hoeller commented Indeed, it looks like we should completely ignore HEAD requests in |
David Goblirsch commented That seems ok to me; without the ShallowEtagHeaderFilter, the HEAD response is what I expected. |
David Goblirsch commented I just upgraded to Spring 4.3.7. Using ShallowEtagHeaderFilter, I no longer get an ETag in response to a HEAD, only to GET. But the Content-Length is still zero for HEAD instead of the size that GET would have returned. If I do not register the ShallowEtagFilter, I get the non-zero Content-Length in response to HEAD, but, of course, I do not get an ETag with a GET response. So the "fix" stopped generating an ETag for HEAD but still says the Content-Length is zero. |
Juergen Hoeller commented David Goblirsch, since 4.3.7 is already out, let's keep this JIRA issue here closed. Please create a follow-up issue against 4.3.7, about |
David Goblirsch opened SPR-15261 and commented
In response to HEAD, now handled by Spring for
@GetMapping
methods as of 4.3+, the HTTP spec says that it "should" include the same headers that GET would include, except that four header parameters are considered "optional". Content-Length is one of these optional headers for HEAD requests. BUT when it is included, it is supposed to have the same value as it would have been for GET, i.e., the length of the response body. My@RestController
@GetMapping
methods return the correct non-zero value for GET requests but are setting Content-Length: 0 for HEAD requests.This is using Spring 4.3.6 on both JBoss 6.1 (yes, very old) and WildFly 10.1.
Affects: 4.3.6
Reference URL: http://stackoverflow.com/questions/27868314/avoiding-content-length-in-head-response
Issue Links:
Referenced from: commits b732251, 45b27a8
The text was updated successfully, but these errors were encountered: