Consistent support for if-(un)modified-since as ZonedDateTime/Instant
Includes DefaultRequestBodyUriSpec pre-resolving URI for HttpRequest. Issue: SPR-17571
This commit is contained in:
parent
199be6aec5
commit
a240cfcf2f
|
@ -1079,6 +1079,24 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
return getETagValuesAsList(IF_MATCH);
|
return getETagValuesAsList(IF_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
public void setIfModifiedSince(ZonedDateTime ifModifiedSince) {
|
||||||
|
setZonedDateTime(IF_MODIFIED_SINCE, ifModifiedSince.withZoneSameInstant(GMT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
public void setIfModifiedSince(Instant ifModifiedSince) {
|
||||||
|
setInstant(IF_MODIFIED_SINCE, ifModifiedSince);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (new) value of the {@code If-Modified-Since} header.
|
* Set the (new) value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
@ -1119,6 +1137,24 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
return getETagValuesAsList(IF_NONE_MATCH);
|
return getETagValuesAsList(IF_NONE_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
public void setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince) {
|
||||||
|
setZonedDateTime(IF_UNMODIFIED_SINCE, ifUnmodifiedSince.withZoneSameInstant(GMT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
public void setIfUnmodifiedSince(Instant ifUnmodifiedSince) {
|
||||||
|
setInstant(IF_UNMODIFIED_SINCE, ifUnmodifiedSince);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (new) value of the {@code If-Unmodified-Since} header.
|
* Set the (new) value of the {@code If-Unmodified-Since} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
@ -1143,11 +1179,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
/**
|
/**
|
||||||
* Set the time the resource was last changed, as specified by the
|
* Set the time the resource was last changed, as specified by the
|
||||||
* {@code Last-Modified} header.
|
* {@code Last-Modified} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since
|
* @since 5.1.4
|
||||||
* January 1, 1970 GMT.
|
|
||||||
*/
|
*/
|
||||||
public void setLastModified(long lastModified) {
|
public void setLastModified(ZonedDateTime lastModified) {
|
||||||
setDate(LAST_MODIFIED, lastModified);
|
setZonedDateTime(LAST_MODIFIED, lastModified.withZoneSameInstant(GMT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1162,10 +1197,11 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
/**
|
/**
|
||||||
* Set the time the resource was last changed, as specified by the
|
* Set the time the resource was last changed, as specified by the
|
||||||
* {@code Last-Modified} header.
|
* {@code Last-Modified} header.
|
||||||
* @since 5.1.4
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setLastModified(ZonedDateTime lastModified) {
|
public void setLastModified(long lastModified) {
|
||||||
setZonedDateTime(LAST_MODIFIED, lastModified.withZoneSameInstant(GMT));
|
setDate(LAST_MODIFIED, lastModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1283,20 +1319,20 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
* Set the given date under the given header name after formatting it as a string
|
* Set the given date under the given header name after formatting it as a string
|
||||||
* using the RFC-1123 date-time formatter. The equivalent of
|
* using the RFC-1123 date-time formatter. The equivalent of
|
||||||
* {@link #set(String, String)} but for date headers.
|
* {@link #set(String, String)} but for date headers.
|
||||||
* @since 5.1.4
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public void setInstant(String headerName, Instant date) {
|
public void setZonedDateTime(String headerName, ZonedDateTime date) {
|
||||||
setZonedDateTime(headerName, ZonedDateTime.ofInstant(date, GMT));
|
set(headerName, DATE_FORMATTERS[0].format(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the given date under the given header name after formatting it as a string
|
* Set the given date under the given header name after formatting it as a string
|
||||||
* using the RFC-1123 date-time formatter. The equivalent of
|
* using the RFC-1123 date-time formatter. The equivalent of
|
||||||
* {@link #set(String, String)} but for date headers.
|
* {@link #set(String, String)} but for date headers.
|
||||||
* @since 5.0
|
* @since 5.1.4
|
||||||
*/
|
*/
|
||||||
public void setZonedDateTime(String headerName, ZonedDateTime date) {
|
public void setInstant(String headerName, Instant date) {
|
||||||
set(headerName, DATE_FORMATTERS[0].format(date));
|
setZonedDateTime(headerName, ZonedDateTime.ofInstant(date, GMT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1643,25 +1679,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
return formatHeaders(this.headers);
|
return formatHeaders(this.headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helps to format HTTP header values, as HTTP header values themselves can
|
|
||||||
* contain comma-separated values, can become confusing with regular
|
|
||||||
* {@link Map} formatting that also uses commas between entries.
|
|
||||||
* @param headers the headers to format
|
|
||||||
* @return the headers to a String
|
|
||||||
* @since 5.1.4
|
|
||||||
*/
|
|
||||||
public static String formatHeaders(MultiValueMap<String, String> headers) {
|
|
||||||
return headers.entrySet().stream()
|
|
||||||
.map(entry -> {
|
|
||||||
List<String> values = entry.getValue();
|
|
||||||
return entry.getKey() + ":" + (values.size() == 1 ?
|
|
||||||
"\"" + values.get(0) + "\"" :
|
|
||||||
values.stream().map(s -> "\"" + s + "\"").collect(Collectors.joining(", ")));
|
|
||||||
})
|
|
||||||
.collect(Collectors.joining(", ", "[", "]"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@code HttpHeaders} object that can only be read, not written to.
|
* Return a {@code HttpHeaders} object that can only be read, not written to.
|
||||||
|
@ -1689,6 +1706,25 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helps to format HTTP header values, as HTTP header values themselves can
|
||||||
|
* contain comma-separated values, can become confusing with regular
|
||||||
|
* {@link Map} formatting that also uses commas between entries.
|
||||||
|
* @param headers the headers to format
|
||||||
|
* @return the headers to a String
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
public static String formatHeaders(MultiValueMap<String, String> headers) {
|
||||||
|
return headers.entrySet().stream()
|
||||||
|
.map(entry -> {
|
||||||
|
List<String> values = entry.getValue();
|
||||||
|
return entry.getKey() + ":" + (values.size() == 1 ?
|
||||||
|
"\"" + values.get(0) + "\"" :
|
||||||
|
values.stream().map(s -> "\"" + s + "\"").collect(Collectors.joining(", ")));
|
||||||
|
})
|
||||||
|
.collect(Collectors.joining(", ", "[", "]"));
|
||||||
|
}
|
||||||
|
|
||||||
// Package-private: used in ResponseCookie
|
// Package-private: used in ResponseCookie
|
||||||
static String formatDate(long date) {
|
static String formatDate(long date) {
|
||||||
Instant instant = Instant.ofEpochMilli(date);
|
Instant instant = Instant.ofEpochMilli(date);
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.springframework.http;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
@ -327,6 +329,20 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
*/
|
*/
|
||||||
B acceptCharset(Charset... acceptableCharsets);
|
B acceptCharset(Charset... acceptableCharsets);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of the {@code If-Modified-Since} header.
|
||||||
|
* @param ifModifiedSince the new value of the header
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
B ifModifiedSince(ZonedDateTime ifModifiedSince);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of the {@code If-Modified-Since} header.
|
||||||
|
* @param ifModifiedSince the new value of the header
|
||||||
|
* @since 5.1.4
|
||||||
|
*/
|
||||||
|
B ifModifiedSince(Instant ifModifiedSince);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of the {@code If-Modified-Since} header.
|
* Set the value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
@ -438,6 +454,18 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BodyBuilder ifModifiedSince(ZonedDateTime ifModifiedSince) {
|
||||||
|
this.headers.setIfModifiedSince(ifModifiedSince);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BodyBuilder ifModifiedSince(Instant ifModifiedSince) {
|
||||||
|
this.headers.setIfModifiedSince(ifModifiedSince);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BodyBuilder ifModifiedSince(long ifModifiedSince) {
|
public BodyBuilder ifModifiedSince(long ifModifiedSince) {
|
||||||
this.headers.setIfModifiedSince(ifModifiedSince);
|
this.headers.setIfModifiedSince(ifModifiedSince);
|
||||||
|
|
|
@ -350,6 +350,26 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
*/
|
*/
|
||||||
B eTag(String etag);
|
B eTag(String etag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @param lastModified the last modified date
|
||||||
|
* @return this builder
|
||||||
|
* @since 5.1.4
|
||||||
|
* @see HttpHeaders#setLastModified(ZonedDateTime)
|
||||||
|
*/
|
||||||
|
B lastModified(ZonedDateTime lastModified);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
* {@code Last-Modified} header.
|
||||||
|
* @param lastModified the last modified date
|
||||||
|
* @return this builder
|
||||||
|
* @since 5.1.4
|
||||||
|
* @see HttpHeaders#setLastModified(Instant)
|
||||||
|
*/
|
||||||
|
B lastModified(Instant lastModified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the time the resource was last changed, as specified by the
|
* Set the time the resource was last changed, as specified by the
|
||||||
* {@code Last-Modified} header.
|
* {@code Last-Modified} header.
|
||||||
|
@ -361,26 +381,6 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
*/
|
*/
|
||||||
B lastModified(long lastModified);
|
B lastModified(long lastModified);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the time the resource was last changed, as specified by the
|
|
||||||
* {@code Last-Modified} header.
|
|
||||||
* @param lastModified the last modified date
|
|
||||||
* @return this builder
|
|
||||||
* @since 5.1.4
|
|
||||||
* @see HttpHeaders#setLastModified(long)
|
|
||||||
*/
|
|
||||||
B lastModified(Instant lastModified);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the time the resource was last changed, as specified by the
|
|
||||||
* {@code Last-Modified} header.
|
|
||||||
* @param lastModified the last modified date
|
|
||||||
* @return this builder
|
|
||||||
* @since 5.1.4
|
|
||||||
* @see HttpHeaders#setLastModified(long)
|
|
||||||
*/
|
|
||||||
B lastModified(ZonedDateTime lastModified);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the location of a resource, as specified by the {@code Location} header.
|
* Set the location of a resource, as specified by the {@code Location} header.
|
||||||
* @param location the location
|
* @param location the location
|
||||||
|
@ -512,7 +512,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BodyBuilder lastModified(long date) {
|
public BodyBuilder lastModified(ZonedDateTime date) {
|
||||||
this.headers.setLastModified(date);
|
this.headers.setLastModified(date);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BodyBuilder lastModified(ZonedDateTime date) {
|
public BodyBuilder lastModified(long date) {
|
||||||
this.headers.setLastModified(date);
|
this.headers.setLastModified(date);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@ package org.springframework.web.reactive.function.client;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -275,9 +273,7 @@ class DefaultWebClient implements WebClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultRequestBodyUriSpec ifModifiedSince(ZonedDateTime ifModifiedSince) {
|
public DefaultRequestBodyUriSpec ifModifiedSince(ZonedDateTime ifModifiedSince) {
|
||||||
ZonedDateTime gmt = ifModifiedSince.withZoneSameInstant(ZoneId.of("GMT"));
|
getHeaders().setIfModifiedSince(ifModifiedSince);
|
||||||
String headerValue = DateTimeFormatter.RFC_1123_DATE_TIME.format(gmt);
|
|
||||||
getHeaders().set(HttpHeaders.IF_MODIFIED_SINCE, headerValue);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,13 +323,16 @@ class DefaultWebClient implements WebClient {
|
||||||
if (defaultRequest != null) {
|
if (defaultRequest != null) {
|
||||||
defaultRequest.accept(this);
|
defaultRequest.accept(this);
|
||||||
}
|
}
|
||||||
URI uri = (this.uri != null ? this.uri : uriBuilderFactory.expand(""));
|
return ClientRequest.create(this.httpMethod, initUri())
|
||||||
return ClientRequest.create(this.httpMethod, uri)
|
|
||||||
.headers(headers -> headers.addAll(initHeaders()))
|
.headers(headers -> headers.addAll(initHeaders()))
|
||||||
.cookies(cookies -> cookies.addAll(initCookies()))
|
.cookies(cookies -> cookies.addAll(initCookies()))
|
||||||
.attributes(attributes -> attributes.putAll(this.attributes));
|
.attributes(attributes -> attributes.putAll(this.attributes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private URI initUri() {
|
||||||
|
return (this.uri != null ? this.uri : uriBuilderFactory.expand(""));
|
||||||
|
}
|
||||||
|
|
||||||
private HttpHeaders initHeaders() {
|
private HttpHeaders initHeaders() {
|
||||||
if (CollectionUtils.isEmpty(this.headers)) {
|
if (CollectionUtils.isEmpty(this.headers)) {
|
||||||
return (defaultHeaders != null ? defaultHeaders : new HttpHeaders());
|
return (defaultHeaders != null ? defaultHeaders : new HttpHeaders());
|
||||||
|
@ -371,25 +370,21 @@ class DefaultWebClient implements WebClient {
|
||||||
|
|
||||||
private HttpRequest createRequest() {
|
private HttpRequest createRequest() {
|
||||||
return new HttpRequest() {
|
return new HttpRequest() {
|
||||||
|
private final URI uri = initUri();
|
||||||
private HttpHeaders headers = initHeaders();
|
private final HttpHeaders headers = initHeaders();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpMethod getMethod() {
|
public HttpMethod getMethod() {
|
||||||
return httpMethod;
|
return httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMethodValue() {
|
public String getMethodValue() {
|
||||||
return httpMethod.name();
|
return httpMethod.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getURI() {
|
public URI getURI() {
|
||||||
return uri;
|
return this.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpHeaders getHeaders() {
|
public HttpHeaders getHeaders() {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
|
@ -410,16 +405,12 @@ class DefaultWebClient implements WebClient {
|
||||||
|
|
||||||
private final List<StatusHandler> statusHandlers = new ArrayList<>(1);
|
private final List<StatusHandler> statusHandlers = new ArrayList<>(1);
|
||||||
|
|
||||||
|
DefaultResponseSpec(Mono<ClientResponse> responseMono, Supplier<HttpRequest> requestSupplier) {
|
||||||
DefaultResponseSpec(Mono<ClientResponse> responseMono,
|
|
||||||
Supplier<HttpRequest> requestSupplier) {
|
|
||||||
this.responseMono = responseMono;
|
this.responseMono = responseMono;
|
||||||
this.requestSupplier = requestSupplier;
|
this.requestSupplier = requestSupplier;
|
||||||
this.statusHandlers.add(DEFAULT_STATUS_HANDLER);
|
this.statusHandlers.add(DEFAULT_STATUS_HANDLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseSpec onStatus(Predicate<HttpStatus> statusPredicate,
|
public ResponseSpec onStatus(Predicate<HttpStatus> statusPredicate,
|
||||||
Function<ClientResponse, Mono<? extends Throwable>> exceptionFunction) {
|
Function<ClientResponse, Mono<? extends Throwable>> exceptionFunction) {
|
||||||
|
@ -473,8 +464,7 @@ class DefaultWebClient implements WebClient {
|
||||||
return bodyPublisher;
|
return bodyPublisher;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return errorFunction.apply(createResponseException(response,
|
return errorFunction.apply(createResponseException(response, this.requestSupplier.get()));
|
||||||
this.requestSupplier.get()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,8 +476,9 @@ class DefaultWebClient implements WebClient {
|
||||||
.onErrorResume(ex2 -> Mono.empty()).thenReturn(ex);
|
.onErrorResume(ex2 -> Mono.empty()).thenReturn(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Mono<WebClientResponseException> createResponseException(ClientResponse response,
|
private static Mono<WebClientResponseException> createResponseException(
|
||||||
HttpRequest request) {
|
ClientResponse response, HttpRequest request) {
|
||||||
|
|
||||||
return DataBufferUtils.join(response.body(BodyExtractors.toDataBuffers()))
|
return DataBufferUtils.join(response.body(BodyExtractors.toDataBuffers()))
|
||||||
.map(dataBuffer -> {
|
.map(dataBuffer -> {
|
||||||
byte[] bytes = new byte[dataBuffer.readableByteCount()];
|
byte[] bytes = new byte[dataBuffer.readableByteCount()];
|
||||||
|
@ -527,7 +518,6 @@ class DefaultWebClient implements WebClient {
|
||||||
|
|
||||||
private final BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction;
|
private final BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction;
|
||||||
|
|
||||||
|
|
||||||
public StatusHandler(Predicate<HttpStatus> predicate,
|
public StatusHandler(Predicate<HttpStatus> predicate,
|
||||||
BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction) {
|
BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction) {
|
||||||
|
|
||||||
|
@ -537,7 +527,6 @@ class DefaultWebClient implements WebClient {
|
||||||
this.exceptionFunction = exceptionFunction;
|
this.exceptionFunction = exceptionFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean test(HttpStatus status) {
|
public boolean test(HttpStatus status) {
|
||||||
return this.predicate.test(status);
|
return this.predicate.test(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,13 +158,13 @@ class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityResponse.Builder<T> lastModified(Instant lastModified) {
|
public EntityResponse.Builder<T> lastModified(ZonedDateTime lastModified) {
|
||||||
this.headers.setLastModified(lastModified);
|
this.headers.setLastModified(lastModified);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityResponse.Builder<T> lastModified(ZonedDateTime lastModified) {
|
public EntityResponse.Builder<T> lastModified(Instant lastModified) {
|
||||||
this.headers.setLastModified(lastModified);
|
this.headers.setLastModified(lastModified);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,13 +158,13 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerResponse.BodyBuilder lastModified(Instant lastModified) {
|
public ServerResponse.BodyBuilder lastModified(ZonedDateTime lastModified) {
|
||||||
this.headers.setLastModified(lastModified);
|
this.headers.setLastModified(lastModified);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerResponse.BodyBuilder lastModified(ZonedDateTime lastModified) {
|
public ServerResponse.BodyBuilder lastModified(Instant lastModified) {
|
||||||
this.headers.setLastModified(lastModified);
|
this.headers.setLastModified(lastModified);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,6 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
|
||||||
@Override
|
@Override
|
||||||
public final Mono<Void> writeTo(ServerWebExchange exchange, Context context) {
|
public final Mono<Void> writeTo(ServerWebExchange exchange, Context context) {
|
||||||
writeStatusAndHeaders(exchange.getResponse());
|
writeStatusAndHeaders(exchange.getResponse());
|
||||||
|
|
||||||
Instant lastModified = Instant.ofEpochMilli(headers().getLastModified());
|
Instant lastModified = Instant.ofEpochMilli(headers().getLastModified());
|
||||||
HttpMethod httpMethod = exchange.getRequest().getMethod();
|
HttpMethod httpMethod = exchange.getRequest().getMethod();
|
||||||
if (SAFE_METHODS.contains(httpMethod) && exchange.checkNotModified(headers().getETag(), lastModified)) {
|
if (SAFE_METHODS.contains(httpMethod) && exchange.checkNotModified(headers().getETag(), lastModified)) {
|
||||||
|
|
|
@ -190,10 +190,9 @@ public interface EntityResponse<T> extends ServerResponse {
|
||||||
* January 1, 1970 GMT.
|
* January 1, 1970 GMT.
|
||||||
* @param lastModified the last modified date
|
* @param lastModified the last modified date
|
||||||
* @return this builder
|
* @return this builder
|
||||||
* @since 5.1.4
|
|
||||||
* @see HttpHeaders#setLastModified(long)
|
* @see HttpHeaders#setLastModified(long)
|
||||||
*/
|
*/
|
||||||
Builder<T> lastModified(Instant lastModified);
|
Builder<T> lastModified(ZonedDateTime lastModified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the time the resource was last changed, as specified by the
|
* Set the time the resource was last changed, as specified by the
|
||||||
|
@ -202,9 +201,10 @@ public interface EntityResponse<T> extends ServerResponse {
|
||||||
* January 1, 1970 GMT.
|
* January 1, 1970 GMT.
|
||||||
* @param lastModified the last modified date
|
* @param lastModified the last modified date
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 5.1.4
|
||||||
* @see HttpHeaders#setLastModified(long)
|
* @see HttpHeaders#setLastModified(long)
|
||||||
*/
|
*/
|
||||||
Builder<T> lastModified(ZonedDateTime lastModified);
|
Builder<T> lastModified(Instant lastModified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the location of a resource, as specified by the {@code Location} header.
|
* Set the location of a resource, as specified by the {@code Location} header.
|
||||||
|
|
|
@ -281,19 +281,19 @@ public interface ServerResponse {
|
||||||
* {@code Last-Modified} header.
|
* {@code Last-Modified} header.
|
||||||
* @param lastModified the last modified date
|
* @param lastModified the last modified date
|
||||||
* @return this builder
|
* @return this builder
|
||||||
* @since 5.1.4
|
|
||||||
* @see HttpHeaders#setLastModified(long)
|
* @see HttpHeaders#setLastModified(long)
|
||||||
*/
|
*/
|
||||||
B lastModified(Instant lastModified);
|
B lastModified(ZonedDateTime lastModified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the time the resource was last changed, as specified by the
|
* Set the time the resource was last changed, as specified by the
|
||||||
* {@code Last-Modified} header.
|
* {@code Last-Modified} header.
|
||||||
* @param lastModified the last modified date
|
* @param lastModified the last modified date
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 5.1.4
|
||||||
* @see HttpHeaders#setLastModified(long)
|
* @see HttpHeaders#setLastModified(long)
|
||||||
*/
|
*/
|
||||||
B lastModified(ZonedDateTime lastModified);
|
B lastModified(Instant lastModified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the location of a resource, as specified by the {@code Location} header.
|
* Set the location of a resource, as specified by the {@code Location} header.
|
||||||
|
|
Loading…
Reference in New Issue