fix: allow multiple body parser coexist#59
Open
tangxinfa wants to merge 3 commits into
Open
Conversation
by sync listen events on ctx.req, multiple body parser coexist is safe. json parser's returnRawBody option can provide untouched request body, we can use it to do signature validation if required, but co-body commonly use by high level middlewares, and not expose a option for user to customize. allow multiple body parser coexist is a more elegant solution.
dead-horse
reviewed
Aug 6, 2017
| .then(function() { | ||
| return raw(inflate(req), opts); | ||
| }) | ||
| return raw(inflate(req), opts) |
Member
There was a problem hiding this comment.
I think why we write this code is becaulse inflate will throw in some situation, so we need to wrap it in a promise chain.
| var app = koa(); | ||
|
|
||
| app.use(function *(next){ | ||
| this.request.textParser = parse.text(this); |
Member
There was a problem hiding this comment.
can't we just check the content-type before call parse[method]?
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.
by sync listen events on ctx.req, multiple body parser coexist is safe.
json parser's returnRawBody option can provide untouched request body,
we can use it to do signature validation if required,
but co-body commonly use by high level middlewares,
and not expose a option for user to customize.
allow multiple body parser coexist is a more elegant solution.