update servlet push cookie handling to servlet 6.1 behaviour

This commit is contained in:
gregw 2024-06-25 20:34:13 +10:00
parent 98aa755dd8
commit 82ab704769
2 changed files with 4 additions and 2 deletions

View File

@ -782,7 +782,8 @@ public class ServletApiRequest implements HttpServletRequest
if (httpCookie == null)
continue;
if (httpCookie.isExpired())
// this should be httpCookie.isExpired(), but because of an error in the servlet spec it is
if (httpCookie.isExpired() || (httpCookie.getMaxAge() < 0))
{
for (Iterator<Object> i = cookies.iterator(); i.hasNext();)
{

View File

@ -57,9 +57,10 @@ public class PushedResourcesTest extends AbstractTest
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
Cookie cookie0 = new Cookie("C0", "v0");
cookie0.setMaxAge(0);
cookie0.setMaxAge(-1);
response.addCookie(cookie0);
Cookie cookie1 = new Cookie("C1", "v1");
cookie1.setMaxAge(1);
response.addCookie(cookie1);
String target = request.getRequestURI();