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);     });   }); }); 

Comments

Post a Comment

Popular posts from this blog

css - Text drops down with smaller window -

php - Boolean search on database with 5 million rows, very slow -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -