Reset Pragma header in WebContentGenerator

As filter-based libraries and projects (such as Spring Security) may
use the "Pragma" header in HTTP responses, WebContentGenerator should
make sure that such headers are overwritten to avoid clashes with
the HTTP caching headers set by the HTTP caching configuration.

Issue: SPR-13252
This commit is contained in:
Felix
2015-07-17 14:50:39 +02:00
committed by Brian Clozel
parent d8fb6c557d
commit 09e3fc40e5
2 changed files with 34 additions and 0 deletions

View File

@@ -105,6 +105,34 @@ public class WebContentInterceptorTests {
assertThat(cacheControlHeaders, Matchers.emptyIterable());
}
// SPR-13252
@Test
public void cachingConfigAndPragmaHeader() throws Exception {
WebContentInterceptor interceptor = new WebContentInterceptor();
interceptor.setCacheSeconds(10);
response.setHeader("Pragma", "no-cache");
interceptor.preHandle(request, response, null);
Iterable<String> pragmaHeaders = response.getHeaders("Pragma");
assertThat(pragmaHeaders, Matchers.contains(""));
}
// SPR-13252
@SuppressWarnings("deprecation")
@Test
public void http10CachingConfigAndPragmaHeader() throws Exception {
WebContentInterceptor interceptor = new WebContentInterceptor();
interceptor.setCacheSeconds(10);
interceptor.setAlwaysMustRevalidate(true);
response.setHeader("Pragma", "no-cache");
interceptor.preHandle(request, response, null);
Iterable<String> pragmaHeaders = response.getHeaders("Pragma");
assertThat(pragmaHeaders, Matchers.contains(""));
}
@SuppressWarnings("deprecation")
@Test
public void http10CachingConfigAndSpecificMapping() throws Exception {