hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Multiple Cookie headers in request

Open NAR opened this issue 1 year ago • 1 comments

Hello!

I was playing around with hackney and tried to set multiple cookies in the same request. I used this example code:

hackney:request(get,"http://httpbin.org/cookies",[{<<"Accept">>,<<"application/json">>}],<<>>,[{cookie,[{<<"test1">>,<<"value1">>,[]},{<<"test2">>,<<"value2">>,[]}]}, {use_cookies,true}]).

When I checked the sent request with Wireshark, I saw this:

GET /cookies HTTP/1.1
Accept: application/json
Host: httpbin.org
User-Agent: hackney/1.18.1
Cookie: test1=value1; Version=1
Cookie: test2=value2; Version=1

However, RFC 6265 explicitly says that "When the user agent generates an HTTP request, the user agent MUST NOT attach more than one Cookie header field.". Is it intentional that hackney adds multiple Cookie headers to the request or is it a bug?

NAR avatar Apr 19 '23 18:04 NAR

it was surely intentional :) But there may have been some confiusion with the Set-Cookie header. A fix for it would be nice

benoitc avatar Oct 10 '23 12:10 benoitc