Saturday, 15 March 2014

javascript - Why do we need res.on('data'... defined for POST even if we are not doing anything with the data? -


This issue got the debugging code where the following action was not performed:

  var Req = http .request (option, function (res) {// res.on ('error', CB (mistake)) res.on ('end', function () {cb ();})}} ;  

Although the following is done:

  var req = http.request (option, function (res) {// res.on ('error' , Cb (err)) res.on ('data', function (chuck) {// why do we need it?}) Res.on ('end', function () {cb ();}); });    

res is the variable one. If you click on the link and scroll down, you may receive:

Note that the 'end' event will not fire unless Data is not fully used. / P>

By adding 'data' event handlers, you use data.


No comments:

Post a Comment