ignore invalid cache control values (#1619)

This commit is contained in:
Athou
2024-12-02 18:43:44 +01:00
parent 8ccb59ed18
commit a073d843ab
2 changed files with 23 additions and 2 deletions

View File

@@ -94,7 +94,7 @@ class HttpGetterTest {
.withContentType(MediaType.APPLICATION_ATOM_XML)
.withHeader(HttpHeaders.LAST_MODIFIED, "123456")
.withHeader(HttpHeaders.ETAG, "78910")
.withHeader(HttpHeaders.CACHE_CONTROL, "max-age=60"));
.withHeader(HttpHeaders.CACHE_CONTROL, "max-age=60, must-revalidate"));
HttpResult result = getter.get(this.feedUrl);
Assertions.assertArrayEquals(feedContent, result.getContent());
@@ -105,6 +105,18 @@ class HttpGetterTest {
Assertions.assertEquals(this.feedUrl, result.getUrlAfterRedirect());
}
@Test
void ignoreInvalidCacheControlValue() throws Exception {
this.mockServerClient.when(HttpRequest.request().withMethod("GET"))
.respond(HttpResponse.response()
.withBody(feedContent)
.withContentType(MediaType.APPLICATION_ATOM_XML)
.withHeader(HttpHeaders.CACHE_CONTROL, "max-age=60; must-revalidate"));
HttpResult result = getter.get(this.feedUrl);
Assertions.assertEquals(Duration.ZERO, result.getValidFor());
}
@ParameterizedTest
@ValueSource(
ints = { HttpStatus.SC_MOVED_PERMANENTLY, HttpStatus.SC_MOVED_TEMPORARILY, HttpStatus.SC_TEMPORARY_REDIRECT,