Skip to content

Instantly share code, notes, and snippets.

@lxe
Created December 14, 2014 02:17
Show Gist options
  • Select an option

  • Save lxe/57a7182e03020f0ed062 to your computer and use it in GitHub Desktop.

Select an option

Save lxe/57a7182e03020f0ed062 to your computer and use it in GitHub Desktop.
// This will "hang"
http.request('http://localhost:3000/')
.on('response', function onResponse(response) {
response.pipe(require('concat-stream')(function (data) {
console.log(data);
}));
})
.end();
// Adding 'data' handler makes it terminate
http.request('http://localhost:3000/')
.on('response', function onResponse(response) {
response.on('data', function noop() { }) // adding this makes it terminate propely
response.pipe(require('concat-stream')(function (data) {
console.log(data);
}));
})
.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment