Problem: Setting setWriteWeakETag to true causes the content-length
header to be removed from the response headers. Without this flag, it sends content-length
along normally.
If this is desired, this "side effect" should be documented, because content-length
is important for frontend applications to show progress (among other things).
Why it matters: Combining GZIP compression with ETag only works with weak ETags, otherwise GZIP compression won't work.
Configuration:
@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
ShallowEtagHeaderFilter filter = new ShallowEtagHeaderFilter();
filter.setWriteWeakETag(true);
return filter;
}
Documentation: here and here make no mention of this.
Comment From: bclozel
As far as I know this filter does not remove the "Content-Length" header at all. Is it possible that the Servlet container removes the content-length header because it compresses the response on the fly and doesn't know the actual length before writing the resource?
In this case, I would argue that this should be documented by the Servlet container.
Comment From: mdmm13
As far as I know this filter does not remove the "Content-Length" header at all. Is it possible that the Servlet container removes the content-length header because it compresses the response on the fly and doesn't know the actual length before writing the resource?
In this case, I would argue that this should be documented by the Servlet container.
Indeed, so this is caused by content compression, which only works with this flag, so I had it backwards. Might be worth documenting the link between setWriteWeakETag and GZIP. Will close as this belongs elsewhere.