Skip to content

Conversation

@Jarvx
Copy link

@Jarvx Jarvx commented Oct 21, 2025

Issue: #11819

Bug description

Calling MutableHttpRequest.cookie(s) is expected to keep a single Cookie header updated. However, multiple Cookie headers are created depending on the request implementation.

Root cause & Fix

The test reproduces the problem for SimpleHttpRequest by adding cookies, it expects exactly one Cookie header value with the latest value for duplicate names and correct semantics.
On the original code, SimpleHttpRequest.updateCookies used headers.add(...) per cookie, which produced multiple Cookie header entries (one per cookie), causing the test to fail.

The patch fixes this by building a single combined Cookie header string (joined with "; ") and setting it once via headers.set(...), thus preventing multiple header entries.

Steps to reproduce

Please use this command to see the output from provided test:

./gradlew :test-suite-kotlin-ksp:test

@Jarvx Jarvx changed the title Fix 11819 Fix 11819: updating SimpleHttpRequest.updateCookies to remove existing cookie headers Oct 21, 2025
@Jarvx
Copy link
Author

Jarvx commented Oct 24, 2025

I'll close this pr first because the CI fails.

@Jarvx Jarvx closed this Oct 24, 2025

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CookieHeaderSingleValueTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test should be placed in where other cookie related tests are keep in the io.micronaut.http.cookie package of the micronaut-http module

Copy link
Author

@Jarvx Jarvx Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll move it to the folder http/src/test/ . Please understand that it's not easy to find perfect test case for me at the moment. I'll need your feedback for this information.

@Jarvx Jarvx reopened this Oct 24, 2025
@Jarvx Jarvx changed the title Fix 11819: updating SimpleHttpRequest.updateCookies to remove existing cookie headers [GenAI] Fix 11819: updating SimpleHttpRequest.updateCookies to remove existing cookie headers Oct 24, 2025
@Jarvx
Copy link
Author

Jarvx commented Oct 31, 2025

I have improved the logic in the test file and the bug fix. Also added more comments.

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

Successfully merging this pull request may close these issues.

2 participants