2014-02-07 136 views
0

这是我发送http请求的代码。为什么我的请求没有结束,有什么不对吗?在节点Js中结束HTTP请求

var req = http.request(options, function(res) { 
     res.setEncoding('utf8'); 
     res.on('data', function(chunk) { 
      console.log('Response: ' + chunk); 
     }); 
    }); 

    req.write(uid); 
    req.end();   //i think this line will end the requset, but not. 

感谢您的回答家伙。

回答

0

我发现我错过结束与res.end();

var req = http.request(options, function(res) { 
     res.setEncoding('utf8'); 
     res.on('data', function(chunk) { 
     console.log('Response: ' + chunk); 
     }); 
    }); 

    req.write(uid); 
    req.end(); 
    res.end(); 
响应