Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EE10 Unable to use Cookie attributes with HttpServletResponse.addCookie(jakarta.servlet.http.Cookie) #10227

Closed
ekupcik opened this issue Aug 4, 2023 · 4 comments · Fixed by #10228
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@ekupcik
Copy link

ekupcik commented Aug 4, 2023

Jetty version(s)
12 Beta 4

Description
While trying to use Cookie.setAttribute("SameSite",...) without any success I figured out that HttpCookieFacade.getAttributes() always returns Collections.emptyMap() instead of delegating it to the underlying Cookie instance.

@ekupcik ekupcik added the Bug For general bugs on Jetty side label Aug 4, 2023
@joakime
Copy link
Contributor

joakime commented Aug 4, 2023

Can you show your code?
What technique you are using?

@joakime
Copy link
Contributor

joakime commented Aug 4, 2023

Never mind. I was able to replicate with ...

        HttpServlet testServlet = new HttpServlet()
        {
            @Override
            protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
            {
                resp.setCharacterEncoding("utf-8");
                resp.setContentType("text/plain");

                Cookie cookie = new Cookie("key", "foo");
                cookie.setAttribute("SameSite", "Lax");
                resp.addCookie(cookie);

                resp.getWriter().println("hello");
            }
        };

PR incoming.

@joakime joakime self-assigned this Aug 4, 2023
@joakime joakime moved this to 🏗 In progress in Jetty 12.0.1 - FROZEN Aug 4, 2023
@joakime joakime changed the title EE10 ServletApiResponse.HttpCookieFacade.getAttributes() always returns Collections.emptyMap() EE10 Unable to use Cookie attributes with HttpServletResponse.addCookie(jakarta.servlet.http.Cookie) Aug 4, 2023
joakime added a commit that referenced this issue Aug 4, 2023
@joakime
Copy link
Contributor

joakime commented Aug 4, 2023

Opened PR #10228

joakime added a commit that referenced this issue Aug 5, 2023
…okie attributes (#10228)

* Issue #10227 - HttpServletResponse.addCookie(Cookie) support for Cookie attributes
@joakime joakime moved this to ✅ Done in Jetty 12.0.0 Aug 5, 2023
@joakime
Copy link
Contributor

joakime commented Aug 5, 2023

Merged PR #10228

@joakime joakime closed this as completed Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
2 participants