Support cookie w/ only Expires attribute in MockHttpServletResponse
Prior to this commit, MockHttpServletResponse only included the Expires attribute in the generated Cookie header if the Max-Age attribute had also been set. This commit supports including the Expires attribute in the generated Cookie Header even when the Max-Age attribute has not been set. Closes gh-26558
This commit is contained in:
committed by
Sam Brannen
parent
e17ca9a4e9
commit
40661d62c1
@@ -378,10 +378,10 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
buf.append("; Domain=").append(cookie.getDomain());
|
||||
}
|
||||
int maxAge = cookie.getMaxAge();
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
|
||||
if (maxAge >= 0) {
|
||||
buf.append("; Max-Age=").append(maxAge);
|
||||
buf.append("; Expires=");
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
|
||||
if (expires != null) {
|
||||
buf.append(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME));
|
||||
}
|
||||
@@ -391,6 +391,11 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
buf.append(headers.getFirst(HttpHeaders.EXPIRES));
|
||||
}
|
||||
}
|
||||
else if (expires != null) {
|
||||
buf.append("; Expires=");
|
||||
buf.append(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME));
|
||||
}
|
||||
|
||||
|
||||
if (cookie.getSecure()) {
|
||||
buf.append("; Secure");
|
||||
|
||||
Reference in New Issue
Block a user