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

HEAD response has "Content-Length: 0" for @RestController @GetMapping methods [SPR-15337] #19900

Closed
spring-projects-issues opened this issue Mar 9, 2017 · 3 comments
Assignees

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 9, 2017

David Goblirsch opened SPR-15337 and commented

When including ShallowEtagHeaderFilter in a REST application, HEAD responses no longer include an ETag header as of 4.3.7, but they still have zero for the Content-Length header. If I do not activate a ShallowEtagHeaderFilter, the response to HEAD has the Content-Length header value set to the size of the response body that GET would have returned, which is the desired behavior.


Affects: 4.3.7

Reference URL: #19826

Referenced from: commits spring-attic/spring-framework-issues@6a1802f

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

I've looked at this and this doesn't seem to be strictly related to ShallowEtagHeaderFilter, since the Servlet response has its internal "Content-Length" value set already after the filter chain has been called. This has something to do with the dispatching/handling of the response, then.

I'll report back once I've narrowed down the origin of this behavior.

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

Hi David Goblirsch!

Sorry about the late reply.
I was sure I had reproduced this, but looking back at my repro project, I can't see the issue anymore.

I've created a repro project here that you can run with mvn package cargo:run.

I'm getting the following result on the CLI:

➜  ~ http :8080/SPR-15337/
HTTP/1.1 200
Content-Length: 4
Content-Type: text/plain;charset=ISO-8859-1
Date: Thu, 08 Mar 2018 13:34:32 GMT
ETag: "0033bd94b1168d7e4f0d644c3c95e35bf"

TEST

➜  ~ http HEAD :8080/SPR-15337/
HTTP/1.1 200
Content-Length: 4
Content-Type: text/plain;charset=ISO-8859-1
Date: Thu, 08 Mar 2018 13:34:37 GMT

Did I miss something here?

@spring-projects-issues
Copy link
Collaborator Author

David Goblirsch commented

In my case I was trying to get XML and JSON payloads.  Your example returns a simple string. I wonder if that has something to do with it.

I am behind a firewall and I cannot pull your example in to elaborate on it.

 

 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants