Merge branch '5.3.x'
This commit is contained in:
@@ -126,6 +126,16 @@ class ServletWebRequestHttpMethodsTests {
|
||||
assertPreconditionFailed();
|
||||
}
|
||||
|
||||
@SafeHttpMethodsTest
|
||||
void ifUnModifiedSinceShouldSetHeadersWithSafeMethod(String method) {
|
||||
setUpRequest(method);
|
||||
Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
|
||||
Instant oneMinuteAgo = now.minus(1, ChronoUnit.MINUTES);
|
||||
servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, now.toEpochMilli());
|
||||
assertThat(request.checkNotModified(oneMinuteAgo.toEpochMilli())).isFalse();
|
||||
assertOkWithLastModified(oneMinuteAgo);
|
||||
}
|
||||
|
||||
@SafeHttpMethodsTest
|
||||
void ifNoneMatchShouldMatchIdenticalETagValue(String method) {
|
||||
setUpRequest(method);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -307,4 +307,18 @@ class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
assertThat(exchange.getResponse().getHeaders().getLastModified()).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkNotModifiedTimestampConditionalWithSafeMethod() throws Exception {
|
||||
String eTag = "\"Foo\"";
|
||||
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("/")
|
||||
.ifUnmodifiedSince(currentDate.toEpochMilli()).build();
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||
assertThat(exchange.checkNotModified(eTag, oneMinuteAgo)).isFalse();
|
||||
assertThat(exchange.getResponse().getStatusCode()).isNull();
|
||||
assertThat(exchange.getResponse().getHeaders().getLastModified()).isEqualTo(oneMinuteAgo.toEpochMilli());
|
||||
assertThat(exchange.getResponse().getHeaders().getETag()).isEqualTo(eTag);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user