Skip to content
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

RestController should not consume request content #66043

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

jaymode
Copy link
Member

@jaymode jaymode commented Dec 8, 2020

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.

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
@jaymode jaymode added >bug :Core/Infra/REST API REST infrastructure and utilities v7.11.0 labels Dec 8, 2020
@jaymode jaymode requested review from rjernst and tlrx December 8, 2020 16:50
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Dec 8, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@tlrx
Copy link
Member

tlrx commented Dec 10, 2020

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.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think of this as a bug, and so think back porting is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/REST API REST infrastructure and utilities Team:Core/Infra Meta label for core/infra team v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants