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
fix: make query param order deterministic when adding params #239
Conversation
I think it would be good, to also have the example that you provided inside a test case, i.e. add |
haha. that's funny. i originally wrote a test for it but then deleted it because i thought it might not be desired behaviour for the future. i'll re-add |
updated |
bump? |
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.
The newly added test should be split into 3 test cases
@@ -333,6 +333,32 @@ class AhcWSRequestSpec extends Specification with Mockito with DefaultBodyReadab | |||
request.getUrl must contain("p1=v1") | |||
} | |||
|
|||
"preserve query param order" in { |
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.
basically this should be split into multipe tests.
@schmitch thanks for clarifying. updated. |
/cc @marcospereira guess this can be merged |
any chance we could get this in? its blocking a project |
WDYT @marcospereira ? |
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.
LGTM - as you say a better behaviour would be to avoid any reordering even if there are params with the same name, but I'm happy that this is an improvement because it is deterministic.
@richdougherty thank you! |
Backported to 1.x.x branch. |
Pull Request Checklist
Fixes
Fixes #48
Purpose
Ensure deterministic query param order when adding params through the WSRequest interface.
This does not address order when adding to a query param that already contains a value.
for example
will yield
p1=v1&p1=v3&p2=v2
which is still not perfect but is at least deterministicBackground Context
I wanted to make the minimal code change to achieve deterministic behaviour.
When generating digital signatures of urls (for example of an Authorization header) it's important to have a deterministic order to be able to correctly compute the digest.
References
playframework/playframework#6884
#102