-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 [Bug]: Ctx.GetReqHeaders
doesn't respect multiple fields with same name
#2594
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
I think we need to change signature to fix the bug https://github.com/gofiber/fiber/blob/master/ctx.go#L654 Also getrespheaders needs to be fixed, too. |
I don't think the signature needs to be changed. All the function would need to do is to join all the values using
So a header of
would result in a map with key |
Yes it's also an option but making them slice seems more logical to me. Joining headers might be bad idea for several cases. i.e when i have a comma in header value, it will be difficult to parse it |
RFC 9110 is pretty specific about this in demanding that field values that can contain commas need to be quoted. But I agree it can get complicated quickly depending on the individual header field. Go also uses a |
What do you think @gaby @ReneWerner87 |
the objection is correct, just don't know if we should change the signature That would be another breaking change breaking change would still work if necessary, but then I want to be sure that we don't make the whole thing complicated, because currently it is a simple function for simple access i.e. we have to be clear whether we want to adjust all other simple cases with the signature change and thus adjust the ease of access based on these 3% cases and thus cause a breaking change or whether the simple solution with the comma separated values would also work currently not sure, the signature change seems to be more correct, but also makes it more complicated |
Should the initial bug be fixed with this? When I'm making request with I'm using latest version 2.51.0. |
Wow. My bad. While testing I simply duplicated the first header and I didn't pay attention to the context of the header itself. Thanks for your response. |
Bug Description
When calling
Ctx.GetReqHeaders
on a request with this header:Then the resulting map contains only the last field value.
See the relevant RFC section.
How to Reproduce
Steps to reproduce the behavior:
curl localhost:3000 -H 'Accept: text/plain' -H 'Accept: application/json'
Expected Behavior
The logs should show the value of both
Accept
fields:Fiber Version
v2.48.0
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: