2

我了解通常的 HTTP 请求生命周期,我想做的是:

向端点发出请求,当所有数据都发送完毕后,我想立即关闭连接,忽略任何可能的答案。

请注意,我不想只是忽略答案,我真的不想听一个,因为连接将被关闭=)

4

1 回答 1

2

只是不要连接客户端数据事件。

app.post('/something', function(req,res) {
   client.post(...., function(res2){
       //let the posted value and response finish
       //won't do anything with it
       res2.resume(); 

       //if you want to return after post, but before response data is read.
       //comment out the res.end below, and use this one.
       // res.end("done");
   });

   //if you are just wanting to fire and forget the post request...
   res.end("done");
});
于 2013-08-22T00:40:31.807 回答