Remove deprecated web APIs
This commit also marks for removal APIs that were deprecated a long time ago but were not marked for removal. See gh-33809
This commit is contained in:
parent
5044b70a40
commit
810da11bb5
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,6 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
@ -36,7 +35,6 @@ import org.springframework.util.StreamUtils;
|
||||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of the Content-Disposition type and parameters as defined in RFC 6266.
|
* Representation of the Content-Disposition type and parameters as defined in RFC 6266.
|
||||||
|
@ -85,34 +83,17 @@ public final class ContentDisposition {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Charset charset;
|
private final Charset charset;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final Long size;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final ZonedDateTime creationDate;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final ZonedDateTime modificationDate;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final ZonedDateTime readDate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor. See static factory methods in this class.
|
* Private constructor. See static factory methods in this class.
|
||||||
*/
|
*/
|
||||||
private ContentDisposition(@Nullable String type, @Nullable String name, @Nullable String filename,
|
private ContentDisposition(@Nullable String type, @Nullable String name, @Nullable String filename,
|
||||||
@Nullable Charset charset, @Nullable Long size, @Nullable ZonedDateTime creationDate,
|
@Nullable Charset charset) {
|
||||||
@Nullable ZonedDateTime modificationDate, @Nullable ZonedDateTime readDate) {
|
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
this.size = size;
|
|
||||||
this.creationDate = creationDate;
|
|
||||||
this.modificationDate = modificationDate;
|
|
||||||
this.readDate = readDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,53 +158,6 @@ public final class ContentDisposition {
|
||||||
return this.charset;
|
return this.charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value of the {@literal size} parameter, or {@code null} if not defined.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nullable
|
|
||||||
public Long getSize() {
|
|
||||||
return this.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value of the {@literal creation-date} parameter, or {@code null} if not defined.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nullable
|
|
||||||
public ZonedDateTime getCreationDate() {
|
|
||||||
return this.creationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value of the {@literal modification-date} parameter, or {@code null} if not defined.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nullable
|
|
||||||
public ZonedDateTime getModificationDate() {
|
|
||||||
return this.modificationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the value of the {@literal read-date} parameter, or {@code null} if not defined.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nullable
|
|
||||||
public ZonedDateTime getReadDate() {
|
|
||||||
return this.readDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
|
@ -231,17 +165,12 @@ public final class ContentDisposition {
|
||||||
ObjectUtils.nullSafeEquals(this.type, that.type) &&
|
ObjectUtils.nullSafeEquals(this.type, that.type) &&
|
||||||
ObjectUtils.nullSafeEquals(this.name, that.name) &&
|
ObjectUtils.nullSafeEquals(this.name, that.name) &&
|
||||||
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
|
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
|
||||||
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
|
ObjectUtils.nullSafeEquals(this.charset, that.charset)));
|
||||||
ObjectUtils.nullSafeEquals(this.size, that.size) &&
|
|
||||||
ObjectUtils.nullSafeEquals(this.creationDate, that.creationDate)&&
|
|
||||||
ObjectUtils.nullSafeEquals(this.modificationDate, that.modificationDate)&&
|
|
||||||
ObjectUtils.nullSafeEquals(this.readDate, that.readDate)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename,
|
return ObjectUtils.nullSafeHash(this.type, this.name,this.filename, this.charset);
|
||||||
this.charset, this.size, this.creationDate, this.modificationDate, this.readDate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,25 +199,6 @@ public final class ContentDisposition {
|
||||||
sb.append(encodeRfc5987Filename(this.filename, this.charset));
|
sb.append(encodeRfc5987Filename(this.filename, this.charset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.size != null) {
|
|
||||||
sb.append("; size=");
|
|
||||||
sb.append(this.size);
|
|
||||||
}
|
|
||||||
if (this.creationDate != null) {
|
|
||||||
sb.append("; creation-date=\"");
|
|
||||||
sb.append(RFC_1123_DATE_TIME.format(this.creationDate));
|
|
||||||
sb.append('\"');
|
|
||||||
}
|
|
||||||
if (this.modificationDate != null) {
|
|
||||||
sb.append("; modification-date=\"");
|
|
||||||
sb.append(RFC_1123_DATE_TIME.format(this.modificationDate));
|
|
||||||
sb.append('\"');
|
|
||||||
}
|
|
||||||
if (this.readDate != null) {
|
|
||||||
sb.append("; read-date=\"");
|
|
||||||
sb.append(RFC_1123_DATE_TIME.format(this.readDate));
|
|
||||||
sb.append('\"');
|
|
||||||
}
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +241,7 @@ public final class ContentDisposition {
|
||||||
* Return an empty content disposition.
|
* Return an empty content disposition.
|
||||||
*/
|
*/
|
||||||
public static ContentDisposition empty() {
|
public static ContentDisposition empty() {
|
||||||
return new ContentDisposition("", null, null, null, null, null, null, null);
|
return new ContentDisposition("", null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -376,7 +286,7 @@ public final class ContentDisposition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (attribute.equals("filename") && (filename == null)) {
|
else if (attribute.equals("filename") && (filename == null)) {
|
||||||
if (value.startsWith("=?") ) {
|
if (value.startsWith("=?")) {
|
||||||
Matcher matcher = BASE64_ENCODED_PATTERN.matcher(value);
|
Matcher matcher = BASE64_ENCODED_PATTERN.matcher(value);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
Base64.Decoder decoder = Base64.getDecoder();
|
Base64.Decoder decoder = Base64.getDecoder();
|
||||||
|
@ -415,39 +325,12 @@ public final class ContentDisposition {
|
||||||
filename = value;
|
filename = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (attribute.equals("size") ) {
|
|
||||||
size = Long.parseLong(value);
|
|
||||||
}
|
|
||||||
else if (attribute.equals("creation-date")) {
|
|
||||||
try {
|
|
||||||
creationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
|
|
||||||
}
|
|
||||||
catch (DateTimeParseException ex) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (attribute.equals("modification-date")) {
|
|
||||||
try {
|
|
||||||
modificationDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
|
|
||||||
}
|
|
||||||
catch (DateTimeParseException ex) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (attribute.equals("read-date")) {
|
|
||||||
try {
|
|
||||||
readDate = ZonedDateTime.parse(value, RFC_1123_DATE_TIME);
|
|
||||||
}
|
|
||||||
catch (DateTimeParseException ex) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException("Invalid content disposition format");
|
throw new IllegalArgumentException("Invalid content disposition format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ContentDisposition(type, name, filename, charset, size, creationDate, modificationDate, readDate);
|
return new ContentDisposition(type, name, filename, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> tokenize(String headerValue) {
|
private static List<String> tokenize(String headerValue) {
|
||||||
|
@ -714,42 +597,6 @@ public final class ContentDisposition {
|
||||||
*/
|
*/
|
||||||
Builder filename(@Nullable String filename, @Nullable Charset charset);
|
Builder filename(@Nullable String filename, @Nullable Charset charset);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@literal size} parameter.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Builder size(@Nullable Long size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@literal creation-date} parameter.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Builder creationDate(@Nullable ZonedDateTime creationDate);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@literal modification-date} parameter.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Builder modificationDate(@Nullable ZonedDateTime modificationDate);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@literal read-date} parameter.
|
|
||||||
* @deprecated since 5.2.3 as per
|
|
||||||
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
|
|
||||||
* to be removed in a future release.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Builder readDate(@Nullable ZonedDateTime readDate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the content disposition.
|
* Build the content disposition.
|
||||||
*/
|
*/
|
||||||
|
@ -770,17 +617,6 @@ public final class ContentDisposition {
|
||||||
@Nullable
|
@Nullable
|
||||||
private Charset charset;
|
private Charset charset;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private Long size;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private ZonedDateTime creationDate;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private ZonedDateTime modificationDate;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private ZonedDateTime readDate;
|
|
||||||
|
|
||||||
public BuilderImpl(String type) {
|
public BuilderImpl(String type) {
|
||||||
Assert.hasText(type, "'type' must not be not empty");
|
Assert.hasText(type, "'type' must not be not empty");
|
||||||
|
@ -806,38 +642,9 @@ public final class ContentDisposition {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Builder size(@Nullable Long size) {
|
|
||||||
this.size = size;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Builder creationDate(@Nullable ZonedDateTime creationDate) {
|
|
||||||
this.creationDate = creationDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Builder modificationDate(@Nullable ZonedDateTime modificationDate) {
|
|
||||||
this.modificationDate = modificationDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Builder readDate(@Nullable ZonedDateTime readDate) {
|
|
||||||
this.readDate = readDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContentDisposition build() {
|
public ContentDisposition build() {
|
||||||
return new ContentDisposition(this.type, this.name, this.filename, this.charset,
|
return new ContentDisposition(this.type, this.name, this.filename, this.charset);
|
||||||
this.size, this.creationDate, this.modificationDate, this.readDate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,26 +44,6 @@ public abstract class HttpMediaTypeException extends ServletException implements
|
||||||
private final Object[] messageDetailArguments;
|
private final Object[] messageDetailArguments;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new HttpMediaTypeException.
|
|
||||||
* @param message the exception message
|
|
||||||
* @deprecated as of 6.0
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected HttpMediaTypeException(String message) {
|
|
||||||
this(message, Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new HttpMediaTypeException with a list of supported media types.
|
|
||||||
* @param supportedMediaTypes the list of supported media types
|
|
||||||
* @deprecated as of 6.0
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected HttpMediaTypeException(String message, List<MediaType> supportedMediaTypes) {
|
|
||||||
this(message, supportedMediaTypes, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new HttpMediaTypeException with a list of supported media types.
|
* Create a new HttpMediaTypeException with a list of supported media types.
|
||||||
* @param supportedMediaTypes the list of supported media types
|
* @param supportedMediaTypes the list of supported media types
|
||||||
|
|
|
@ -123,15 +123,6 @@ public class RestClientResponseException extends RestClientException {
|
||||||
return this.statusCode;
|
return this.statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the raw HTTP status code value.
|
|
||||||
* @deprecated in favor of {@link #getStatusCode()}, for removal in 7.0
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.0")
|
|
||||||
public int getRawStatusCode() {
|
|
||||||
return this.statusCode.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the HTTP status text.
|
* Return the HTTP status text.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,17 +76,6 @@ public class MethodNotAllowedException extends ResponseStatusException {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to {@link #getHeaders()}.
|
|
||||||
* @since 5.1.13
|
|
||||||
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.0")
|
|
||||||
@Override
|
|
||||||
public HttpHeaders getResponseHeaders() {
|
|
||||||
return getHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the HTTP method for the failed request.
|
* Return the HTTP method for the failed request.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,17 +76,6 @@ public class NotAcceptableStatusException extends ResponseStatusException {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to {@link #getHeaders()}.
|
|
||||||
* @since 5.1.13
|
|
||||||
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.0")
|
|
||||||
@Override
|
|
||||||
public HttpHeaders getResponseHeaders() {
|
|
||||||
return getHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of supported content types in cases when the Accept
|
* Return the list of supported content types in cases when the Accept
|
||||||
* header is parsed but not supported, or an empty list otherwise.
|
* header is parsed but not supported, or an empty list otherwise.
|
||||||
|
|
|
@ -110,23 +110,9 @@ public class ResponseStatusException extends ErrorResponseException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return headers to add to the error response, for example, "Allow", "Accept", etc.
|
* Return headers to add to the error response, for example, "Allow", "Accept", etc.
|
||||||
* <p>By default, delegates to {@link #getResponseHeaders()} for backwards
|
|
||||||
* compatibility.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HttpHeaders getHeaders() {
|
public HttpHeaders getHeaders() {
|
||||||
return getResponseHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return headers associated with the exception that should be added to the
|
|
||||||
* error response, for example, "Allow", "Accept", etc.
|
|
||||||
* <p>The default implementation in this class returns empty headers.
|
|
||||||
* @since 5.1.13
|
|
||||||
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.0")
|
|
||||||
public HttpHeaders getResponseHeaders() {
|
|
||||||
return HttpHeaders.EMPTY;
|
return HttpHeaders.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,14 +168,4 @@ public class UnsupportedMediaTypeStatusException extends ResponseStatusException
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to {@link #getHeaders()}.
|
|
||||||
* @deprecated as of 6.0 in favor of {@link #getHeaders()}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.0")
|
|
||||||
@Override
|
|
||||||
public HttpHeaders getResponseHeaders() {
|
|
||||||
return getHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ import org.springframework.util.Assert;
|
||||||
* @since 1.1.4
|
* @since 1.1.4
|
||||||
* @see #addCookie
|
* @see #addCookie
|
||||||
* @see #removeCookie
|
* @see #removeCookie
|
||||||
* @deprecated as of 6.0 in favor of {@link org.springframework.http.ResponseCookie}
|
* @deprecated as of 6.0 in favor of {@link org.springframework.http.ResponseCookie} for removal in 7.1
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(since = "6.0", forRemoval = true)
|
||||||
public class CookieGenerator {
|
public class CookieGenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
package org.springframework.http;
|
package org.springframework.http;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -35,17 +33,13 @@ import static org.springframework.http.ContentDisposition.parse;
|
||||||
*/
|
*/
|
||||||
class ContentDispositionTests {
|
class ContentDispositionTests {
|
||||||
|
|
||||||
private static final DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME;
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
void parseFilenameQuoted() {
|
void parseFilenameQuoted() {
|
||||||
assertThat(parse("form-data; name=\"foo\"; filename=\"foo.txt\"; size=123"))
|
assertThat(parse("form-data; name=\"foo\"; filename=\"foo.txt\""))
|
||||||
.isEqualTo(ContentDisposition.formData()
|
.isEqualTo(ContentDisposition.formData()
|
||||||
.name("foo")
|
.name("foo")
|
||||||
.filename("foo.txt")
|
.filename("foo.txt")
|
||||||
.size(123L)
|
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,49 +171,12 @@ class ContentDispositionTests {
|
||||||
assertThat(cd.toString()).isEqualTo("form-data; name=\"foo\"; filename=\"D:\\\\foo\\\\bar.txt\"");
|
assertThat(cd.toString()).isEqualTo("form-data; name=\"foo\"; filename=\"D:\\\\foo\\\\bar.txt\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
void parseWithExtraSemicolons() {
|
void parseWithExtraSemicolons() {
|
||||||
assertThat(parse("form-data; name=\"foo\";; ; filename=\"foo.txt\"; size=123"))
|
assertThat(parse("form-data; name=\"foo\";; ; filename=\"foo.txt\";"))
|
||||||
.isEqualTo(ContentDisposition.formData()
|
.isEqualTo(ContentDisposition.formData()
|
||||||
.name("foo")
|
.name("foo")
|
||||||
.filename("foo.txt")
|
.filename("foo.txt")
|
||||||
.size(123L)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
|
||||||
void parseDates() {
|
|
||||||
ZonedDateTime creationTime = ZonedDateTime.parse("Mon, 12 Feb 2007 10:15:30 -0500", formatter);
|
|
||||||
ZonedDateTime modificationTime = ZonedDateTime.parse("Tue, 13 Feb 2007 10:15:30 -0500", formatter);
|
|
||||||
ZonedDateTime readTime = ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter);
|
|
||||||
|
|
||||||
assertThat(
|
|
||||||
parse("attachment; " +
|
|
||||||
"creation-date=\"" + creationTime.format(formatter) + "\"; " +
|
|
||||||
"modification-date=\"" + modificationTime.format(formatter) + "\"; " +
|
|
||||||
"read-date=\"" + readTime.format(formatter) + "\"")).isEqualTo(
|
|
||||||
ContentDisposition.attachment()
|
|
||||||
.creationDate(creationTime)
|
|
||||||
.modificationDate(modificationTime)
|
|
||||||
.readDate(readTime)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
|
||||||
void parseIgnoresInvalidDates() {
|
|
||||||
ZonedDateTime readTime = ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter);
|
|
||||||
|
|
||||||
assertThat(
|
|
||||||
parse("attachment; " +
|
|
||||||
"creation-date=\"-1\"; " +
|
|
||||||
"modification-date=\"-1\"; " +
|
|
||||||
"read-date=\"" + readTime.format(formatter) + "\"")).isEqualTo(
|
|
||||||
ContentDisposition.attachment()
|
|
||||||
.readDate(readTime)
|
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,16 +195,14 @@ class ContentDispositionTests {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> parse("foo;bar"));
|
assertThatIllegalArgumentException().isThrownBy(() -> parse("foo;bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
void format() {
|
void format() {
|
||||||
assertThat(
|
assertThat(
|
||||||
ContentDisposition.formData()
|
ContentDisposition.formData()
|
||||||
.name("foo")
|
.name("foo")
|
||||||
.filename("foo.txt")
|
.filename("foo.txt")
|
||||||
.size(123L)
|
|
||||||
.build().toString())
|
.build().toString())
|
||||||
.isEqualTo("form-data; name=\"foo\"; filename=\"foo.txt\"; size=123");
|
.isEqualTo("form-data; name=\"foo\"; filename=\"foo.txt\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -422,13 +422,12 @@ class HttpHeadersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
void contentDisposition() {
|
void contentDisposition() {
|
||||||
ContentDisposition disposition = headers.getContentDisposition();
|
ContentDisposition disposition = headers.getContentDisposition();
|
||||||
assertThat(disposition).isNotNull();
|
assertThat(disposition).isNotNull();
|
||||||
assertThat(headers.getContentDisposition()).as("Invalid Content-Disposition header").isEqualTo(ContentDisposition.empty());
|
assertThat(headers.getContentDisposition()).as("Invalid Content-Disposition header").isEqualTo(ContentDisposition.empty());
|
||||||
|
|
||||||
disposition = ContentDisposition.attachment().name("foo").filename("foo.txt").size(123L).build();
|
disposition = ContentDisposition.attachment().name("foo").filename("foo.txt").build();
|
||||||
headers.setContentDisposition(disposition);
|
headers.setContentDisposition(disposition);
|
||||||
assertThat(headers.getContentDisposition()).as("Invalid Content-Disposition header").isEqualTo(disposition);
|
assertThat(headers.getContentDisposition()).as("Invalid Content-Disposition header").isEqualTo(disposition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,10 @@ import org.springframework.web.util.WebUtils;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 17.06.2003
|
* @since 17.06.2003
|
||||||
* @see #setThemeName
|
* @see #setThemeName
|
||||||
* @deprecated as of 6.0 in favor of using CSS, without direct replacement
|
* @deprecated as of 6.0 in favor of using CSS, without direct replacement for removal in 7.1
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.0")
|
@Deprecated(since = "6.0", forRemoval = true)
|
||||||
|
@SuppressWarnings("removal")
|
||||||
public class CookieThemeResolver extends CookieGenerator implements ThemeResolver {
|
public class CookieThemeResolver extends CookieGenerator implements ThemeResolver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -272,6 +272,7 @@ public class MvcNamespaceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // gh-25290
|
@Test // gh-25290
|
||||||
|
@SuppressWarnings("removal")
|
||||||
void testDefaultConfigWithBeansInParentContext() {
|
void testDefaultConfigWithBeansInParentContext() {
|
||||||
StaticApplicationContext parent = new StaticApplicationContext();
|
StaticApplicationContext parent = new StaticApplicationContext();
|
||||||
parent.registerSingleton("localeResolver", CookieLocaleResolver.class);
|
parent.registerSingleton("localeResolver", CookieLocaleResolver.class);
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class ThemeResolverTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("removal")
|
||||||
void cookieThemeResolver() {
|
void cookieThemeResolver() {
|
||||||
internalTest(new CookieThemeResolver(), true, AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME);
|
internalTest(new CookieThemeResolver(), true, AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue