Can't add multiple headers with the same name (cookies)
See original GitHub issueThe code:
val (request, response, result) = reqUrl.httpGet()
.header(Pair("Cookie", "val1=x"),
Pair("Cookie","val2=y"),
Pair("Cookie","val3=z"))
.responseString()
Expected functionality:
All cookies are included in request
Actual functionality:
Only the last Pair with val3 is included in the request
This happens because, in Request.kt line 28, the headers variable is a MutableMap, instead of perhaps an ArrayList of Pairs or a similar datatype.
Multiple headers with the same name is allowed in the HTTP spec, section 4.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
How to handle multiple cookies with the same name?
If I access /example on the server both paths are valid, so I have two cookies named "a"! Since the browser doesn't send...
Read more >multiple headers of the "same name" allowed in http #3591
It seems like the solution here is to either allow multiple "same name" headers, or, fail loudly when the user tries to send...
Read more >Can't add more than one cookie with the same name
Issue. We have two cookies with the same name, but different paths. One of the headers is being ignored.
Read more >URL Fetch cannot get multiple cookie headers [35887589]
Yes, it's a bug. The response contains multiple headers, so the library should return those headers as they are in the response and...
Read more >setcookie - Manual - PHP
Note that the $_COOKIE variable not will hold multiple cookies with the same name. It is legitimate to set two cookies with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SleeplessByte do you have any thoughts on the comment above? I think producing
is almost impossible, however
is what my current pr hope to achieve.
@Fibonacci- your feedback would be warmly welcome!
AAs per the spec, you should add the space: i.e. this would be
Cookie: val1=x; val2=y; val3=z
. Note that I used a semi-colon, which is the correct delimiter. Here is the RFC spec:https://tools.ietf.org/html/rfc7540#section-8.1.2.5
However from experience I know that this format:
is not accepted by ALL nodes out there (especially older software/nodes will simply drop all but the first or drop all but the last).