mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-06 14:12:21 +08:00
Only fire the callback for blocked requests if one was provided
This commit is contained in:
parent
0f20f918be
commit
2300081d43
@ -38,17 +38,18 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
|||||||
continued = true;
|
continued = true;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (callback) {
|
||||||
callback(err);
|
callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.request(options, function (err, response, body) {
|
self.request(options, function (err, response, body) {
|
||||||
var hasCallback = !!callback;
|
var hasCallback = !!callback;
|
||||||
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback);
|
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback);
|
||||||
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {
|
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : callback); // don't fire the callback if hasHttpError did it already
|
||||||
} : callback); // don't fire the callback if hasHttpError did it already
|
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {} : callback); // don't fire the callback if either of the previous already did
|
||||||
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {
|
|
||||||
} : callback); // don't fire the callback if either of the previous already did
|
|
||||||
|
|
||||||
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || null, response, body, {
|
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || null, response, body, {
|
||||||
"hasCallback": hasCallback,
|
"hasCallback": hasCallback,
|
||||||
|
Loading…
Reference in New Issue
Block a user