javascript - node.js pipe restify http client response -
i have exact question, except i'm using restify httpclient:
node.js write http response stream
for clarity, i'm trying this:
var client = restify.createclient({ url: "http://www.google.com" }); client.get("/", function(err,res) { res.pipe(process.stdout); }); it hangs few seconds never writes stdout. i'm trying fetch other google's homepage, example...
i recommend user request this:
var request = require('request'); // npm install request request('http://www.google.com').pipe(process.stdout); looking @ restify's docs seems need wait 'result' event:
var client = restify.createclient({ url: "http://www.google.com" }); client.get("/", function(err,req) { req.on('result',function(err2,res) { res.pipe(process.stdout); res.on('end',function() { process.exit(0); }); }); });
This comment has been removed by the author.
ReplyDeleteThank you for sharing this post. looking forward to read more.
ReplyDeleteWeb Design and Development Company