JS-Rewrite: Preserve query string rewrite when the request contains a body #3172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
During the porting of rewrite_js.js tests into the elixir test suite I've found an erroneous behavior in the JS-rewrite functionality.
When a rewritten request contains a BODY (POST/PUT) and the rewrite rule rewrites the query string, this query string is ignored in the final request. The following case illustrates this issue.
1 - Create a design document with a rule that rewrites the query string, like this one:
any request should be rewritten to
_changes?filter=_docs_ids
2 - Create a couple of docs
3 - Perform a POST request to be rewritten
The expected result for this case is to have only the change for the doc with id 2 in the response, but the full change list is returned. The
filter=_doc_ids
is ignored after the rewritten.This PR changes this behavior and the query string is preserved, so the result for the previous case is the excepted one returning only the change for the doc with id 2.
Testing recommendations
The previous test case has been added to rewrite_js.js tests
Related Issues or Pull Requests
This issue #1612 and the companion PR #1620 are related to this issue
Checklist
rel/overlay/etc/default.ini