benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

Multiple Cookie headers in request #719

Open NAR opened 1 year ago

NAR commented 1 year ago

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?

benoitc commented 1 year ago

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