Skip to content

Commit 2c016c9

Browse files
committed
Merge branch '4.1.x'
2 parents 3835adc + 4676b39 commit 2c016c9

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/factory/cache/ResponseCacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public ResponseCacheManager(CacheKeyGenerator cacheKeyGenerator, Cache cache, Du
8181
this.ignoreNoCacheUpdate = isSkipNoCacheUpdateActive(requestOptions);
8282
this.afterCacheExchangeMutators = List.of(new SetResponseHeadersAfterCacheExchangeMutator(),
8383
new SetStatusCodeAfterCacheExchangeMutator(),
84-
new RemoveHeadersAfterCacheExchangeMutator(HttpHeaders.PRAGMA),
84+
new RemoveHeadersAfterCacheExchangeMutator(HttpHeaders.PRAGMA, HttpHeaders.EXPIRES),
8585
new SetMaxAgeHeaderAfterCacheExchangeMutator(configuredTimeToLive, Clock.systemDefaultZone(),
8686
ignoreNoCacheUpdate),
8787
new SetCacheDirectivesByMaxAgeAfterCacheExchangeMutator());

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/cache/LocalResponseCacheGatewayFilterFactoryTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,21 +353,30 @@ void shouldNotCacheWhenAuthorizationHeaderIsDifferent() {
353353

354354
@Test
355355
void shouldNotReturnPragmaHeaderInNonCachedAndCachedResponses() {
356+
shouldNotReturnHeader(HttpHeaders.PRAGMA);
357+
}
358+
359+
@Test
360+
void shouldNotReturnExpiresHeaderInNonCachedAndCachedResponses() {
361+
shouldNotReturnHeader(HttpHeaders.EXPIRES);
362+
}
363+
364+
private void shouldNotReturnHeader(String header) {
356365
String uri = "/" + UUID.randomUUID() + "/cache/headers";
357366

358367
testClient.get()
359368
.uri(uri)
360369
.header("Host", "www.localresponsecache.org")
361370
.exchange()
362371
.expectHeader()
363-
.doesNotExist(HttpHeaders.PRAGMA);
372+
.doesNotExist(header);
364373

365374
testClient.get()
366375
.uri(uri)
367376
.header("Host", "www.localresponsecache.org")
368377
.exchange()
369378
.expectHeader()
370-
.doesNotExist(HttpHeaders.PRAGMA);
379+
.doesNotExist(header);
371380
}
372381

373382
void assertNonVaryHeaderInContent(String uri, String varyHeader, String varyHeaderValue, String nonVaryHeader,

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/cache/LocalResponseCacheGlobalFilterTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,30 @@ void shouldGlobalCacheResponseWhenRouteDoesNotHaveFilter() {
126126

127127
@Test
128128
void shouldNotReturnPragmaHeaderInNonCachedAndCachedResponses() {
129+
shouldNotReturnHeader(HttpHeaders.PRAGMA);
130+
}
131+
132+
@Test
133+
void shouldNotReturnExpiresHeaderInNonCachedAndCachedResponses() {
134+
shouldNotReturnHeader(HttpHeaders.EXPIRES);
135+
}
136+
137+
private void shouldNotReturnHeader(String header) {
129138
String uri = "/" + UUID.randomUUID() + "/global-cache/headers";
130139

131140
testClient.get()
132141
.uri(uri)
133142
.header("Host", "www.localresponsecache.org")
134143
.exchange()
135144
.expectHeader()
136-
.doesNotExist(HttpHeaders.PRAGMA);
145+
.doesNotExist(header);
137146

138147
testClient.get()
139148
.uri(uri)
140149
.header("Host", "www.localresponsecache.org")
141150
.exchange()
142151
.expectHeader()
143-
.doesNotExist(HttpHeaders.PRAGMA);
152+
.doesNotExist(header);
144153
}
145154

146155
@EnableAutoConfiguration

0 commit comments

Comments
 (0)