Support date properties in Content-Disposition HTTP header
Issue: SPR-15555
This commit is contained in:
@@ -19,6 +19,8 @@ package org.springframework.http;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
@@ -76,6 +78,26 @@ public class ContentDispositionTests {
|
||||
ContentDisposition.parse("foo;bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDates() {
|
||||
ContentDisposition disposition = ContentDisposition
|
||||
.parse("attachment; creation-date=\"Mon, 12 Feb 2007 10:15:30 -0500\"; modification-date=\"Tue, 13 Feb 2007 10:15:30 -0500\"; read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\"");
|
||||
assertEquals(ContentDisposition.builder("attachment")
|
||||
.creationDate(ZonedDateTime.parse("Mon, 12 Feb 2007 10:15:30 -0500", DateTimeFormatter.RFC_1123_DATE_TIME))
|
||||
.modificationDate(ZonedDateTime.parse("Tue, 13 Feb 2007 10:15:30 -0500", DateTimeFormatter.RFC_1123_DATE_TIME))
|
||||
.readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", DateTimeFormatter.RFC_1123_DATE_TIME))
|
||||
.build(), disposition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseInvalidDates() {
|
||||
ContentDisposition disposition = ContentDisposition
|
||||
.parse("attachment; creation-date=\"-1\"; modification-date=\"-1\"; read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\"");
|
||||
assertEquals(ContentDisposition.builder("attachment")
|
||||
.readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", DateTimeFormatter.RFC_1123_DATE_TIME))
|
||||
.build(), disposition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerValue() {
|
||||
ContentDisposition disposition = ContentDisposition.builder("form-data")
|
||||
|
||||
Reference in New Issue
Block a user