RestController should not consume request content#66043
Merged
jaymode merged 1 commit intoelastic:7.xfrom Dec 14, 2020
Merged
Conversation
The change elastic#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 elastic#44902
Collaborator
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Member
|
Thanks @jaymode. This change was not backported as I was afraid it would break some user applications, but I agree that it can be seen as a bug too. Since I don't have a strong opinion about it, I'm deferring the decision to backport to the core infra team. |
rjernst
approved these changes
Dec 14, 2020
Member
rjernst
left a comment
There was a problem hiding this comment.
LGTM. I think of this as a bug, and so think back porting is fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.