Created
December 14, 2014 02:17
-
-
Save lxe/57a7182e03020f0ed062 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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