Sync changes in MockHttpServletResponse test fixture

See gh-26558
This commit is contained in:
Sam Brannen
2021-02-17 14:30:43 +01:00
parent 8f2010d669
commit 33add3350b

View File

@@ -374,10 +374,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));
}
@@ -387,6 +387,10 @@ 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");