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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user