RestController should not consume request content #66043
Merged
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.
The change #37504 modifies the BaseRestHandler to make it reject all requests
that have an unconsumed body. The notion of consumed or unconsumed body
is carried by the RestRequest object and its contentConsumed attribute, which
is set to true when the content() or content(true) methods are used.
In our REST layer, we usually expect the RestHandlers to consume the request
content when needed, but it appears that the RestController always consumes
the content upfront.
This commit changes the content() method used by the RestController so that it
does not mark the content as consumed.
Backport of #44902
Closes #65242
Note to reviewers: this is targeted against 7.x as this is a backport of a fix that was made on master but at the time was not backported. However, I see this as a bug that we should fix which is why I am opening this for backport to 7.x. The review request is more about whether or not we should backport this to 7.x than the actual changes to the code as they have already been approved.