client: add http tracker destroy function

This commit is contained in:
Feross Aboukhadijeh 2015-05-16 22:55:41 -07:00
parent c048f1b2a9
commit ee91dff19d

View File

@ -85,6 +85,11 @@ HTTPTracker.prototype.setInterval = function (intervalMs) {
}
}
HTTPTracker.prototype.destroy = function () {
var self = this
self.destroyed = true
}
HTTPTracker.prototype._request = function (requestUrl, opts, cb) {
var self = this
@ -92,6 +97,7 @@ HTTPTracker.prototype._request = function (requestUrl, opts, cb) {
common.querystringStringify(opts)
get.concat(u, function (err, data, res) {
if (self.destroyed) return
if (err) return self.client.emit('warning', err)
if (res.statusCode !== 200) {
return self.client.emit('warning', new Error('Non-200 response code ' +