micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

MutableHttpRequest doesn't set multiple cookies properly

Open j1m-renwick opened this issue 1 year ago • 0 comments

Expected Behavior

MutableHttpRequest (specifically NettyMutableHttpRequest)'s cookies(Set<Cookie>) method should result in all cookies being set in the request

Actual Behaviour

cookies(Set<Cookie>) results in only one cookie being set (the last one in the set).

This appears to be an issue with the NettyMutableHttpRequest cookie method, which overrides any existing cookie header with the new cookie input.

Steps To Reproduce

invoke the following code in an http-enabled project and observe the resulting request

@ServerFilter("/**")
class IncomingRequestFilter {

    @RequestFilter
    @ExecuteOn(TaskExecutors.BLOCKING)
    void filterRequest(MutableHttpRequest<?> request) {
        Cookie newCookie2 = Cookie.of("COOKIE_1", "one")
        Cookie newCookie = Cookie.of("COOKIE_2", "two")

        Set<Cookie> cookies = new HashSet<>()
        cookies.addAll(newCookie)
        cookies.addAll(newCookie2)

        request.cookies(cookies)
    }
}

Environment Information

No response

Example Application

No response

Version

4.1.6

j1m-renwick avatar Dec 08 '23 10:12 j1m-renwick