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

Http body already parsed #22

Open
runceel opened this issue Sep 9, 2018 · 4 comments · May be fixed by #31
Open

Http body already parsed #22

runceel opened this issue Sep 9, 2018 · 4 comments · May be fixed by #31

Comments

@runceel
Copy link

runceel commented Sep 9, 2018

Thank you for your great product!!
I love it. :)

I found a compatibility issue between pure-express and azure-function-express.

In pure-express, the request body is not parsed. It is raw data.
In azure-function-express, the request body is already parsed. It is object.

My workaround is as below:

app.post('path', 
  (req, res, next) => { req.body = req.rawBody; next(); },
  otherMiddlewares,
  (req, res) => {
    // do something
  });

I couldn't use bodyParser module on azure-function-express.

@yvele
Copy link
Owner

yvele commented Sep 9, 2018

What version of azure-function-express are you using?

@runceel
Copy link
Author

runceel commented Sep 9, 2018

Oh, sorry.
I'm using azure-function-express v2.0.0 on Azure Functions v2.

@runceel
Copy link
Author

runceel commented Sep 10, 2018

Sorry, I taked mistake during write this issue.

A module that I tried is clova-cek-sdk-nodejs.
https://github.com/line/clova-cek-sdk-nodejs

Because the module expect the type of req.body is string or Buffer or parseable by body-parser, I did a workaround previous wrote.
https://github.com/line/clova-cek-sdk-nodejs/blob/master/src/verifierMiddleware.ts#L24

However, body-parser expect a req is behave like stream.
https://github.com/stream-utils/raw-body/blob/master/index.js#L190

Because the IncomingMessage that you provide is not behave like stream, then become to no response.

@dcollien
Copy link

dcollien commented Mar 6, 2019

This appears to be a duplicate of #15 where the req object isn't a stream.

I opened a PR which changes the IncomingMessage (wrapped req object) to be a Readable stream with the rawBody pushed. This seems to fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants