Add Partitioned cookie attribute support for servers
This commit adds support for the "Partitioned" cookie attribute in WebFlux servers and the related testing infrastructure. Note, Undertow does not support this feature at the moment. Closes gh-31454
This commit is contained in:
@@ -98,6 +98,24 @@ public class MockCookie extends Cookie {
|
||||
return getAttribute(SAME_SITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "Partitioned" attribute for this cookie.
|
||||
* @since 6.2
|
||||
* @see <a href="https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1">The Partitioned attribute spec</a>
|
||||
*/
|
||||
public void setPartitioned(boolean partitioned) {
|
||||
setAttribute("Partitioned", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the "Partitioned" attribute is set for this cookie.
|
||||
* @since 6.2
|
||||
* @see <a href="https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1">The Partitioned attribute spec</a>
|
||||
*/
|
||||
public boolean isPartitioned() {
|
||||
return getAttribute("Partitioned") != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that parses the value of the supplied "Set-Cookie" header.
|
||||
* @param setCookieHeader the "Set-Cookie" value; never {@code null} or empty
|
||||
@@ -146,6 +164,9 @@ public class MockCookie extends Cookie {
|
||||
else if (StringUtils.startsWithIgnoreCase(attribute, "Comment")) {
|
||||
cookie.setComment(extractAttributeValue(attribute, setCookieHeader));
|
||||
}
|
||||
else {
|
||||
cookie.setAttribute(attribute, extractAttributeValue(attribute, setCookieHeader));
|
||||
}
|
||||
}
|
||||
return cookie;
|
||||
}
|
||||
|
||||
@@ -481,6 +481,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
if (cookie.isHttpOnly()) {
|
||||
buf.append("; HttpOnly");
|
||||
}
|
||||
if (cookie.getAttribute("Partitioned") != null) {
|
||||
buf.append("; Partitioned");
|
||||
}
|
||||
if (cookie instanceof MockCookie mockCookie) {
|
||||
if (StringUtils.hasText(mockCookie.getSameSite())) {
|
||||
buf.append("; SameSite=").append(mockCookie.getSameSite());
|
||||
|
||||
Reference in New Issue
Block a user