Closed
Description
Related to #6414
Let's add some support to HeaderWriterFilter
for writing headers at the beginning of the request:
public void setShouldWriteHeadersEagerly(boolean shouldWriteHeadersEagerly) {
this.shouldWriteHeadersEagerly = shouldWriteHeadersEagerly;
}
Which would then allow folks to post process the HeaderWriterFilter
and configure it:
http
.headers()
.withObjectPostProcessor(new ObjectPostProcessor<HeaderWriterFilter>() {
public HeaderWriterFilter postProcess(HeaderWriterFilter filter) {
filter.setShouldWriteHeadersEagerly(true);
return filter;
}
}
HeaderWriterFilter
writes headers at the end of the request. However, headers cannot be written after an include.
If the user uses servletContext.getRequestDispatcher(path).include(request, response)
, for example, then the security headers will not get written.
Spring Security is able to wrap HttpServletRequest
so that request.getRequestDispatcher(path).include(request, response)
is captured, but it is not possible to do the same with ServletContext
.