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

req.pipe(request(url)).pipe(res); can not pipe body. Can you tell me how to result it, thanks #2391

Closed
jsspace opened this issue Sep 22, 2016 · 3 comments
Labels

Comments

@jsspace
Copy link

jsspace commented Sep 22, 2016

when I request a response from other server via my node server, I do this:
app.use(function (req, res) {
req.pipe(request(url)).pipe(res).
})
But I use request-debug, find that no req.body to the other server, causing much trouble.
Can you tell me how to result it.
Thanks.

@poonai
Copy link

poonai commented Dec 5, 2016

app.use(function (req, res) {
request(url).pipe(res).
})

try this
cheers!!

@jsspace
Copy link
Author

jsspace commented Dec 6, 2016

Thank you, I found the solution:
express default use 'app.use(body-parser('json'))', which means server get req and parser req.body to json. But pipe need stream to do. so change it to 'app.use(body-parser(raw()))'. raw() parser req.body to stream.

It's my solution.

@stale
Copy link

stale bot commented Nov 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2018
@stale stale bot closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants