8 comments

[ 0.22 ms ] story [ 32.3 ms ] thread
Request is really quite nice. It's the simple high-level counterpart to node's low-level HTTP client. Very useful "sweet spot" in the abstraction levels.
I like how SubStack put it - request is the swiss army knife of HTTP streaming.
This is one of the modules everyone starts to build themselves, then realizes there's a much better version already built.
Unfortunately I've had the opposite experience: trying to use request then finding that I have to build my own. Mainly because it has no good pattern for both streaming and catching errors in a predictable fashion, the streaming isn't true streaming in most cases (try a 5GB file), and with binary files, it's tricky to nail the right encoding.
I agree about the encoding problems, particularly when using buffers. No combination seemed to allow me to download a binary file and then upload. But this was my first few hours with Node so I'm open to correction. In the end I was able to use .pipe which correctly managed the encoding
Just to clarify: the sorts of things I'm using an HTTP Get-type library for are atypical and request is fantastic for 95% percentage of uses. And the library I wrote ( https://github.com/developmentseed/node-get ) isn't recommended for use if you aren't me. Though it does a decent job of staying out of your way.
This is great, can't wait to start replacing old code! No more complicated multi-line monster requests+callbacks.