Return -1 after parse error for Expires header
Issue: SPR-10648
This commit is contained in:
parent
9035a97e18
commit
0f71da5be6
|
|
@ -354,13 +354,21 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time at which the message is no longer valid, as specified by the {@code Expires} header.
|
* Returns the date and time at which the message is no longer valid, as specified by
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* the {@code Expires} header.
|
||||||
|
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT.
|
||||||
|
* Returns -1 when the date is unknown.
|
||||||
|
*
|
||||||
* @return the expires value
|
* @return the expires value
|
||||||
*/
|
*/
|
||||||
public long getExpires() {
|
public long getExpires() {
|
||||||
|
try {
|
||||||
return getFirstDate(EXPIRES);
|
return getFirstDate(EXPIRES);
|
||||||
}
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code If-Modified-Since} header.
|
* Sets the (new) value of the {@code If-Modified-Since} header.
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,14 @@ public class HttpHeadersTests {
|
||||||
assertEquals("Invalid Expires header", "Thu, 18 Dec 2008 10:20:00 GMT", headers.getFirst("expires"));
|
assertEquals("Invalid Expires header", "Thu, 18 Dec 2008 10:20:00 GMT", headers.getFirst("expires"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPR-10648 (example is from INT-3063)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void expiresInvalidDate() {
|
||||||
|
headers.set("Expires", "-1");
|
||||||
|
assertEquals(-1, headers.getExpires());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ifModifiedSince() {
|
public void ifModifiedSince() {
|
||||||
Calendar calendar = new GregorianCalendar(2008, 11, 18, 11, 20);
|
Calendar calendar = new GregorianCalendar(2008, 11, 18, 11, 20);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue