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

Cookie duplication using request.addCookie #7444

Closed
roman0x58 opened this issue May 9, 2024 · 1 comment
Closed

Cookie duplication using request.addCookie #7444

roman0x58 opened this issue May 9, 2024 · 1 comment

Comments

@roman0x58
Copy link

Hi, I'm facing an issue, when adding a cookie with the same name, it results the cookie being presented in request.cookies twice.

The test will fail with List(someCookieName=foo, someCookieName=bar) did not equal List (someCookieName=bar)

val request: Request[IO] = Request()
    .addCookie(RequestCookie("someCookieName", "foo"))
    .addCookie(RequestCookie("someCookieName", "bar"))

request.cookies must equal (RequestCookie("someCookieName", "bar") :: Nil)

If this is the intended behavior, it would be great to have something like replaceCookie or so.

@danicheg
Copy link
Member

I failed to find references in the spec that the Cookie header must contain only unique keys. However, this might be considered a natural behaviour. Given that, I'd suggest modifying the existing Cookie header in the Request via org.http4s.Message#transformHeaders, org.http4s.Message#removeHeader and org.http4s.Message#addHeader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants