Skip to content

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

Open

Description

@loesak

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.

Activity

  1. odrotbohm commented on Jan 15, 2026

    @odrotbohm
    Member

    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.

    The calculation of those headers is out of our control, as it's Spring MVC adding these based on the content negotiation algorithm downstream of our controller depending on the actual object to be returned from the controller. That's one of the reasons we went with the 204 status code, as we don't expect clients to find these headers if there's no content to be transferred.

    As for the item resource, the current design tries to align the status code with the HTTP method. So there's a gravity towards 204. I guess we could move to rather align with what the GET request would return. I'll schedule this for 5.1 M1, as we need to pass this through a minor release process to give folks the chance to adapt to the slightly changed header arrangement then.

  2. spring-projects-issues commented on Jan 22, 2026

    @spring-projects-issues

    If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

  3. spring-projects-issues commented on Jan 29, 2026

    @spring-projects-issues

    Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

  4. loesak commented on Jan 29, 2026

    @loesak
    Author

    @odrotbohm I didn't see any feedback requested.

  5. odrotbohm commented on Jan 29, 2026

    @odrotbohm
    Member

    No worries. I the label back on, to signal that we would take further input / opinion. But that triggers our stale issues automation.

    It's still on my todo list. Reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions