Polishing
This commit is contained in:
parent
1e4c10cef1
commit
dd6cb1b728
|
@ -236,9 +236,9 @@ public final class ContentDisposition {
|
|||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.filename);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.charset);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.size);
|
||||
result = 31 * result + (this.creationDate != null ? this.creationDate.hashCode() : 0);
|
||||
result = 31 * result + (this.modificationDate != null ? this.modificationDate.hashCode() : 0);
|
||||
result = 31 * result + (this.readDate != null ? this.readDate.hashCode() : 0);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.creationDate);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.modificationDate);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.readDate);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,8 @@ public sealed interface HttpStatusCode extends Serializable permits DefaultHttpS
|
|||
* positive number
|
||||
*/
|
||||
static HttpStatusCode valueOf(int code) {
|
||||
Assert.isTrue(code >= 100 && code <= 999, () -> "Code '" + code + "' should be a three-digit positive integer");
|
||||
Assert.isTrue(code >= 100 && code <= 999,
|
||||
() -> "Status code '" + code + "' should be a three-digit positive integer");
|
||||
HttpStatus status = HttpStatus.resolve(code);
|
||||
if (status != null) {
|
||||
return status;
|
||||
|
|
|
@ -115,9 +115,9 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
|
|||
return setStatusCode(statusCode != null ? HttpStatusCode.valueOf(statusCode) : null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public Integer getRawStatusCode() {
|
||||
return this.statusCode != null ? this.statusCode.value() : null;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
|
|||
* @since 5.2.4
|
||||
* @deprecated as of 6.0, in favor of {@link #getStatusCode()}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated(since = "6.0")
|
||||
@Nullable
|
||||
default Integer getRawStatusCode() {
|
||||
HttpStatusCode httpStatus = getStatusCode();
|
||||
return (httpStatus != null ? httpStatus.value() : null);
|
||||
|
|
|
@ -25,20 +25,22 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.springframework.http.ContentDisposition.parse;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ContentDisposition}
|
||||
* Unit tests for {@link ContentDisposition}.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
class ContentDispositionTests {
|
||||
|
||||
private static DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME;
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME;
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void parse() {
|
||||
@Test
|
||||
void parseFilenameQuoted() {
|
||||
assertThat(parse("form-data; name=\"foo\"; filename=\"foo.txt\"; size=123"))
|
||||
.isEqualTo(ContentDisposition.formData()
|
||||
.name("foo")
|
||||
|
@ -72,7 +74,7 @@ class ContentDispositionTests {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test // gh-24112
|
||||
@Test // gh-24112
|
||||
void parseEncodedFilenameWithPaddedCharset() {
|
||||
assertThat(parse("attachment; filename*= UTF-8''some-file.zip"))
|
||||
.isEqualTo(ContentDisposition.attachment()
|
||||
|
@ -80,7 +82,7 @@ class ContentDispositionTests {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test // gh-26463
|
||||
@Test // gh-26463
|
||||
void parseBase64EncodedFilename() {
|
||||
String input = "attachment; filename=\"=?UTF-8?B?5pel5pys6KqeLmNzdg==?=\"";
|
||||
assertThat(parse(input).getFilename()).isEqualTo("日本語.csv");
|
||||
|
@ -95,7 +97,7 @@ class ContentDispositionTests {
|
|||
assertThat(parse(input).getFilename()).isEqualTo("Spring框架为基于Java的现代企业应用程序提供了全面的编程和配置模型.txt");
|
||||
}
|
||||
|
||||
@Test // gh-26463
|
||||
@Test // gh-26463
|
||||
void parseBase64EncodedShiftJISFilename() {
|
||||
String input = "attachment; filename=\"=?SHIFT_JIS?B?k/qWe4zqLmNzdg==?=\"";
|
||||
assertThat(parse(input).getFilename()).isEqualTo("日本語.csv");
|
||||
|
@ -168,8 +170,8 @@ class ContentDispositionTests {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void parseWithExtraSemicolons() {
|
||||
assertThat(parse("form-data; name=\"foo\";; ; filename=\"foo.txt\"; size=123"))
|
||||
.isEqualTo(ContentDisposition.formData()
|
||||
|
@ -179,8 +181,8 @@ class ContentDispositionTests {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@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);
|
||||
|
@ -198,8 +200,8 @@ class ContentDispositionTests {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void parseIgnoresInvalidDates() {
|
||||
ZonedDateTime readTime = ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter);
|
||||
|
||||
|
@ -228,13 +230,8 @@ class ContentDispositionTests {
|
|||
assertThatIllegalArgumentException().isThrownBy(() -> parse("foo;bar"));
|
||||
}
|
||||
|
||||
private static ContentDisposition parse(String input) {
|
||||
return ContentDisposition.parse(input);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void format() {
|
||||
assertThat(
|
||||
ContentDisposition.formData()
|
||||
|
@ -266,14 +263,11 @@ class ContentDispositionTests {
|
|||
.isEqualTo("form-data; name=\"name\"; filename=\"test.txt\"");
|
||||
}
|
||||
|
||||
@Test // gh-24220
|
||||
@Test // gh-24220
|
||||
void formatWithFilenameWithQuotes() {
|
||||
|
||||
BiConsumer<String, String> tester = (input, output) -> {
|
||||
|
||||
assertThat(ContentDisposition.formData().filename(input).build().toString())
|
||||
.isEqualTo("form-data; filename=\"" + output + "\"");
|
||||
|
||||
assertThat(ContentDisposition.formData().filename(input, StandardCharsets.US_ASCII).build().toString())
|
||||
.isEqualTo("form-data; filename=\"" + output + "\"");
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue