spring-projects / spring-projects/spring-data-rest

HEAD response status and headers are not equivalent to those of a GET response

Open
#2,517 5 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Sep 26, 2025.

status: waiting-for-triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.