async-http-client icon indicating copy to clipboard operation
async-http-client copied to clipboard

Cookie explicitly set on the request is getting discarded in favor of the one from the cookie jar

Open Spikhalskiy opened this issue 1 year ago • 0 comments

Expected Behavior

A cookie explicitly specified on a RequestBuilder should take precedence over a cookie stored in cookie jar.

Actual Behavior

cookieStore = httpClient.getCookieStore();
cookieStore.add("some_url", new DefaultCookie("name", "value1"));
BoundRequestBuilder requestBuilder = httpClient.prepareGet("some_url");
requestBuilder.addCookie(new DefaultCookie("name", "value2"));
httpClient.executeRequest(requestBuilder.build())

This code leads to a request being performed with cookie "name":"value1", which is not what is expected by a user when a user explicitly sets a cookie on a RequestBuilder.

Root cause

Cookies from cookie jar are overriding cookies coming from the RequestBuilder here

Affected version

2.12.3, 3.0 pre-releases

Spikhalskiy avatar Jun 17 '24 21:06 Spikhalskiy