-
-
Notifications
You must be signed in to change notification settings - Fork 422
Fix handling of duplicate headers in MultiVerb client #1859
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
base: master
Are you sure you want to change the base?
Conversation
|
Note: this probably needs a CHANGELOG entry. |
|
@gdeest let me know when you want a review for this PR. :) |
|
@tchoutri I think it is reviewable as it is ! :-) |
| -- This implementation retrieves the *first* header with matching name. | ||
| -- It leaves other instances of the same header intact for subsequent extraction, which allows | ||
| -- multiple headers with the same name to be extracted (e.g. Set-Cookie). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaviour should probably be put in the public documentation. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly would you see it ? As module-level Haddock documentation ?
Note that this matches Verb behavior (this was actually motivated by / discovered via #1860 ).
Add test case that directly exercises MultiVerb's extractHeaders function with duplicate header names (Set-Cookie headers). Fails with current implementation, shows discrepancy with Verb (which has a similar test case). The test uses WithHeaders with two Set-Cookie headers and verifies both cookies are properly extracted on the client side.
The previous implementation used Seq.partition to remove ALL headers with the matching name at once. This commit changes its behavior to accept duplicate header names (makes dual `Set-Cookie` test pass).
e5610be to
8cbae7d
Compare
Current handling of duplicate headers in
MultiVerbclient implementation is inconsistent with theVerbbehavior. The latter allows duplicate header names, which is illustrated by a test-case that sets two distinctSet-Cookieheaders. TheMultiVerbimplementation extracts the first matching header upon parsing, and removes the other instances.I believe the
Verbbehavior is the correct choice as it allows some valid use-cases that are otherwise forbidden (e.g. multipleSet-Cookie). It will also allow some invalid behaviors (such as multipleHostheaders) but this is a small price to pay.This PR:
extractHeadersfunction to exhibit the same behavior as theVerbimplementation.