Skip to content

Commit 5b97c47

Browse files
committed
Sync changes in MockHttpServletResponse test fixture
See gh-26558
1 parent 40661d6 commit 5b97c47

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ private String getCookieHeader(Cookie cookie) {
378378
buf.append("; Domain=").append(cookie.getDomain());
379379
}
380380
int maxAge = cookie.getMaxAge();
381+
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
381382
if (maxAge >= 0) {
382383
buf.append("; Max-Age=").append(maxAge);
383384
buf.append("; Expires=");
384-
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
385385
if (expires != null) {
386386
buf.append(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME));
387387
}
@@ -391,6 +391,10 @@ private String getCookieHeader(Cookie cookie) {
391391
buf.append(headers.getFirst(HttpHeaders.EXPIRES));
392392
}
393393
}
394+
else if (expires != null) {
395+
buf.append("; Expires=");
396+
buf.append(expires.format(DateTimeFormatter.RFC_1123_DATE_TIME));
397+
}
394398

395399
if (cookie.getSecure()) {
396400
buf.append("; Secure");

0 commit comments

Comments
 (0)