Description
Current behavior
The set_cookie method does not upsert the new cookie, just append.
❯ curl -i http://localhost:8000/
HTTP/1.1 200 OK
...
set-cookie: foo=bar; Path=/; SameSite=lax
set-cookie: foo=foo; Path=/; SameSite=lax
Expected behavior
Cookies should be deduplicated to avoid redundant set-cookie headers in the response.
❯ curl -i http://localhost:8000/
HTTP/1.1 200 OK
...
set-cookie: foo=foo; Path=/; SameSite=lax
URL to code causing the issue
No response
MCVE
from litestar import Litestar, Response, get
@get("/", sync_to_thread=False)
def test_handler() -> Response:
return Response({}, cookies={"foo": "bar"})
async def after_request(response: Response) -> Response:
response.set_cookie(key="foo", value="foo")
return response
app = Litestar(
route_handlers=[test_handler],
after_request=after_request,
)
Steps to reproduce
Screenshots
No response
Logs
Litestar Version
litestar: the main branch
python: 3.12
Platform
Description
Current behavior
The set_cookie method does not upsert the new cookie, just append.
Expected behavior
Cookies should be deduplicated to avoid redundant
set-cookieheaders in the response.URL to code causing the issue
No response
MCVE
Steps to reproduce
Screenshots
No response
Logs
Litestar Version
litestar: the main branch
python: 3.12
Platform