-
Notifications
You must be signed in to change notification settings - Fork 80
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
Allow non destructive reads of request body #426
Conversation
String remoteUri = routingTargetHandler.getRoutingDestination(multiReadHttpServletRequest); | ||
proxyRequestHandler.postRequest(body, multiReadHttpServletRequest, asyncResponse, URI.create(remoteUri)); |
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.
Why would this apply only to POST and not to others GET, DELETE?
Would it not be safer to use MultiReadHttpServletRequest instead of HttpServletRequest in all cases?
including RoutingGroup codes?
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 GETs and DELETEs won't have bodies, so getReader
and getInputStream
will be null either way
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.
True, hmm.. how about using one type just for unifcation for all cases? even if it doesn't have body?
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.
Yeah, I think that is what @oneonestar was suggesting with the plan to replace HttpServeletRequest
with a dedicated class like TrinoRequestContext
. This is the way to go, but would broaden the scope of this PR by quite a bit. So for now I think we can get by with HttpServletRequest
, using the MultiRead implementation when there is a body
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. Btw would this change not be applied to TrinoQueryProperties too?
String remoteUri = routingTargetHandler.getRoutingDestination(multiReadHttpServletRequest); | ||
proxyRequestHandler.postRequest(body, multiReadHttpServletRequest, asyncResponse, URI.create(remoteUri)); |
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.
True, hmm.. how about using one type just for unifcation for all cases? even if it doesn't have body?
|
Description
HttpServeletRequest
only supports destructive reads of a request's body. This change ensures different components can access the request body without interfering with one another.Fixes #427
Fixes #428
Additional context and related issues
The body of a request is consumed by the
ServeletHandler
s that supply thebody
argument toRouteToBackendResource.postHandler
. It is necessary to re-associate the body with the request so it can be used by downstream query id extraction logic and routing rules.Release notes
(x ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: