[ https://issues.apache.org/jira/browse/HTTPCLIENT-2331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855953#comment-17855953 ]
Oleg Kalnichevski commented on HTTPCLIENT-2331: ----------------------------------------------- > Yes, I see that HttpClient doesn't remove the manually added Cookie headers > but shouldn't it merge all cookies [~nvchaudhari1991] No, it should not. HttpClient does not meddle with manually added headers, pretty much never. What I am going to change in 5.4 is the behavior of HttpClient when there is a Cookie header present in the request message. Most likely I will make it skip Cookie header generation altogether. Oleg > Single cookie header should be sent for multiple cookies > -------------------------------------------------------- > > Key: HTTPCLIENT-2331 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2331 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient (classic) > Reporter: Nikhil Chaudhari > Priority: Major > Attachments: DemoServiceOneController.java, DemoServiceOneLogs.txt, > DemoServiceTwoController.java > > > Single cookie header should be sent for multiple cookies > *Use case* - > When *Cookie* header is added explicitly using {*}setHeader{*}() method and > there exists multiple cookies in cookie store (BasicCookieStore), then for > this use case two Cookie headers are sent by HttpClient. > *Expectation* - Single Cookie header should be sent by Apache HttpClient > where all cookies should be separated by semi-colon > *Actual* - Two Cookie headers are sent by Apache HttpClient, where in cookie > set using setHeader is sent as one cookie Header and cookies in > BasicCookieStore are sent in another Cookie header wherein value is all > cookies separates by semi-colon. > > *Steps to reproduce -* > # Setup two microservices > # 1st microservice will set custom Cookie header as part of API request to > 2nd micro service. > # 2nd microservice will respond back with two Set-Cookie headers > # First time when call is made from 1st micro service to 2nd micro service > only custom cookie header will be sent and BasicCookieStore on 1st > microservice will be updated with cookies that we got from 2nd microservice > # Second time when call is made from 1st micro service to 2nd micro service > both custom cookie and cookies from BasicCookieStore will be sent as separate > Cookie headers. > > {code:java} > 2024-06-18 09:45:28.074 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> GET > /demo-service-two/test HTTP/1.1 > 2024-06-18 09:45:28.074 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> Cookie: > MyCustomCookie=QWERTY > 2024-06-18 09:45:28.074 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> > Accept-Encoding: gzip, x-gzip, deflate > 2024-06-18 09:45:28.075 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> Host: > localhost:8091 > 2024-06-18 09:45:28.075 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> Connection: > keep-alive > 2024-06-18 09:45:28.075 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> User-Agent: > Apache-HttpClient/5.1.3 (Java/17.0.8) > 2024-06-18 09:45:28.075 DEBUG 3540 --- [nio-8090-exec-7] > org.apache.hc.client5.http.headers : http-outgoing-1 >> Cookie: > ServiceTwoSession1=POIUY; ServiceTwoSession2=ZXCVB {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org