feross / simple-get

Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines
MIT License
401 stars 50 forks source link

support external piping #42

Open mafintosh opened 6 years ago

mafintosh commented 6 years ago

Right now there doesn't seem to be a way to do

var req = get.post(...)

pump(coolStream, req)

Would be great to support that :)

bendrucker commented 6 years ago

I added support for using readables as the body in https://github.com/feross/simple-get/pull/30. It's obviously not as elegant as piping to a stream returned by simple-get but that seemed like it would clash too much with the existing interface. At a bare minimum, streaming use can't call req.end. I think this would require a different method/option indicating that the user wants a writable stream.

mafintosh commented 6 years ago

@bendrucker possible solution is to nextTick the req.end() and if req.on('pipe') fires inbetween cancel it.

bendrucker commented 6 years ago

Mmm good point!