Does one call to http.get() pull all data chunks?

66 views
Skip to first unread message

Steve Litt

unread,
Aug 19, 2015, 9:51:42 PM8/19/15
to nodejs
Hi all,

I was doing the "HTTP COLLECT" tutorial that comes with Node.js. I originally had a loop to keep doing http.get() until it came back error or end, but later removed the loop and it still worked,  which implied to me that one call to http.get() pulls *all* chunks of data from the URL.

Does one call to http.get() pull all data chunks?

Thanks,

SteveT

Jimb Esser

unread,
Aug 28, 2015, 10:41:33 PM8/28/15
to nodejs
No tutorials come with Node.js, it looks like you're probably referring to the nodeschool.io tutorials.  They have their own discussion threads hosted on GitHub here: https://github.com/nodeschool/discussions which might be a good place to ask about specific exercises in their tutorials.

To answer your question, one call to http.get does not pull any data, it creates a stream, which (generally) will eventually emit all of the data requested.  If you're calling http.get multiple times, then you're creating multiple requests, each of which will stream the entire response.

Hope this helps,
  Jimb Esser
Reply all
Reply to author
Forward
0 new messages