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

Question about responses as readable streams #153

Closed
ryanwilliamquinn opened this issue Dec 21, 2016 · 3 comments
Closed

Question about responses as readable streams #153

ryanwilliamquinn opened this issue Dec 21, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@ryanwilliamquinn
Copy link

@ryanwilliamquinn ryanwilliamquinn commented Dec 21, 2016

If I use Wreck.request, I can pipe the response, and the text is dumped out to my terminal.

Wreck.request('GET', 'https://github.com/hapijs/wreck', {}, (err, res) => {
  res.pipe(process.stdout)
})

If I use Wreck.get, no text is dumped to my terminal. I think this is because this uses Wreck.read internally, and the readstream already emitted its 'finish' event. Is there a way to re-start the readstream from the beginning? Otherwise, what is the point of documenting that the response is a readable stream in this case?

Wreck.get('https://github.com/hapijs/wreck', {}, (err, res) => {
  res.pipe(process.stdout)
})
@devinivy

This comment has been minimized.

Copy link
Member

@devinivy devinivy commented Dec 21, 2016

I believe that you are right about the stream having been already read. Its contents get funneled into a third payload callback argument that isn't shown in your example code. In this case I agree that the docs stating res is a readable stream is a bit of a "red herring," though correct.

@devinivy devinivy added the question label Dec 21, 2016
@ryanwilliamquinn

This comment has been minimized.

Copy link
Author

@ryanwilliamquinn ryanwilliamquinn commented Dec 21, 2016

I wonder how that can be improved? It did cost me some time trying to understand why I couldn't pipe anything from the response stream.

@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Dec 22, 2016

It just need to state that it is a "used-up" stream and that you cannot pipe it.

@geek geek added documentation and removed question labels Dec 22, 2016
@geek geek self-assigned this Dec 28, 2016
@geek geek added this to the 10.0.1 milestone Dec 28, 2016
@geek geek closed this in #154 Dec 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.