How can I determine if server.HttpResponse stopped without listenng to "end" or "close" events?
What I am trying to achieve is something like this:
http.createServer(function (request, response) {
var foo; // my event emitting object
// ... something compilated happens here ...
foo.onSomeEvent(function () {
if (response.hasEnded) {
// do something
}
});
});
You can check the finished
property on the response object:
if (res.finished) {
...
}
(never used it myself, so not sure if there are any potential problems to take into consideration when using it)
use
if(response.writableEnded){
//doSomething();
}
response.finished is deprecated
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.