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

ServletWebRequest.checkNotModified() methods should treat HEAD identically to GET [SPR-11317] #15941

Closed
spring-projects-issues opened this issue Jan 15, 2014 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Markus Malkusch opened SPR-11317 and commented

ServletWebRequest.checkNotModified() methods don't treat a HEAD request identically to a GET request (in fact they don't consider HEAD at all).

HTTP says:

The HEAD method is identical to GET except that the server MUST NOT
return a message-body in the response. The metainformation contained
in the HTTP headers in response to a HEAD request SHOULD be identical
to the information sent in response to a GET request.

Spring's reference documentation suggests to call WebRequest.checkNotModified() to set the status code to 304:

calling request.checkNotModified(lastModified) and returning null. The
former sets the response status to 304

As a consequence of the current implementation, applications which follow that recommendation violate against HTTP. In simple words: I had some fun debugging my application for a missing 304 status code while firing HEAD requests with wget --server-response --spider on it.

I suggest to respect HEAD in the mentioned methods identically to GET.

For test case and fix see #440


Affects: 3.2.6, 4.0 GA

Reference URL: #440

Backported to: 3.2.7

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch! Fixed for 4.0.1 and 3.2.7 now.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants