-
Notifications
You must be signed in to change notification settings - Fork 227
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
Fixes issue #255: Can't access HTTP request body in java11-vert-x template. #256
base: master
Are you sure you want to change the base?
Conversation
…aas#255 Signed-off-by: Patrik Fortier <[email protected]>
Could you share testing instructions please? I'd like to try it. Before:
After:
|
Tried this change. And it works. |
Sorry I wasn't clear.
Thanks |
Hi, sorry I didn't follow this right away. I took time to make a small example. Before:
The handler for the project should look something like this. This simply returns the request body sent: public void handle(RoutingContext routingContext) {
routingContext.response()
.putHeader("content-type", "application/json;charset=UTF-8")
.end(
routingContext.getBodyAsString()
);
} Calling the function
Logs show something like this:
Applying fix
|
Hi @p-fortier this dropped off my radar. It seems important to be able to access the request body and I wasn't aware that this was not possible with the template! @pmlopes pinged me about this, so I think we should consider revisiting this. Thanks for adding context. |
Please see also #282 - let me know your thoughts on that one. |
@pmlopes can this be merged in your opinion? |
Yes, this will always parse the request body. For security or latency reasons not everyone might want/need it, but is a quick solution. In the refered issue about upgrading the template we shall address this in a user defined way. |
What do you mean "parse"? Is there a way to get the RAW body without this change? |
Yes you can get the raw body, by replicating what the The body handler does a bit more, it handles, http body, form uploads, ensures that files are discarded, limits the size to avoid DoS, etc... |
Signed-off-by: Patrik Fortier [email protected]
Description
Added a
io.vertx.ext.web.handler.BodyHandler
instance to the handlers to populate routingContext with the HTTP request body.Motivation and Context
Which issue(s) this PR fixes
Fixes #255
How Has This Been Tested?
I deployed a function reading the http request body using the modified
Types of changes
Impact to existing users
Adds one handler to the router. According to vertx documentation, the overhead is negligible.
Checklist:
git commit -s
verify.sh
script