spring-projects / spring-projects/spring-security
Write HTTP Headers Eagerly by Default
@rwinch is already working on this.
Since Mar 3, 2026.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Previously, it was not ideal for Spring Security to proactively set HTTP Headers because setting a header meant there was no way for the user to remove a header.
This has changed in Servlet 6.1 where the Javadoc of HttpServletResponse.setHeader(String, String) states:
Passing null as the value removes all headers with the given name.
Users could always override the default headers with a new value. Since servlet 6.1, they can now remove the header.
Spring Security should be updated to set the headers eagerly by default. Users wishing to override headers can now do so.
This does break passivity because today applications that set or adds a single cache control header ensures that Spring Security sets no cache control headers.
- Applications cannot use addHeader if they want to override Spring Security's default headers
- Applications must explicitly override every cache control header that they wish to change
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.