spring-projects / spring-projects/spring-data-rest
HEAD response status and headers are not equivalent to those of a GET response
@odrotbohm is already working on this.
Since Sep 26, 2025.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
My understanding of the specification is that the response from a HEAD request should be (nearly) identical to a GET request with the main exception is that there is no body returned on a HEAD request. Other than that, the status code should be the same and the headers should be the same.
RepositoryEntityController#headCollectionResource returns a 204 when the GET response would return a 200. It is also missing headers for Content-Type and Transfer-Encoding. If the resource is not found, it correctly returns a 404.
RepositoryEntityController#headForItemResource returns a 204 when the GET response would return a 200 OK. In the case of using ETag value to set the request header If-None-Match or similar, if the GET request were to return a 304 Not Modified, the HEAD version of the same request still returns a 204 No Content. It's also adding a Cache-Control header where as the GET request does not.
I haven't checked other endpoints.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.