mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-04 08:02:23 +08:00
Pass response body back to caller for inventory fetching
This commit is contained in:
parent
06df0ecd42
commit
ab037b1931
@ -47,7 +47,7 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
||||
|
||||
self.request(options, function (err, response, body) {
|
||||
var hasCallback = !!callback;
|
||||
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback);
|
||||
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback, body);
|
||||
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : 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 jsonError = options.json && options.checkJsonError !== false && !body ? new Error("Malformed JSON response") : null;
|
||||
@ -85,29 +85,29 @@ SteamCommunity.prototype._notifySessionExpired = function(err) {
|
||||
this.emit('sessionExpired', err);
|
||||
};
|
||||
|
||||
SteamCommunity.prototype._checkHttpError = function(err, response, callback) {
|
||||
SteamCommunity.prototype._checkHttpError = function(err, response, callback, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
callback(err, response, body);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
||||
err = new Error("Not Logged In");
|
||||
callback(err);
|
||||
callback(err, response, body);
|
||||
this._notifySessionExpired(err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (response.statusCode == 403 && response.body && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
||||
err = new Error("Family View Restricted");
|
||||
callback(err);
|
||||
callback(err, response, body);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (response.statusCode >= 400) {
|
||||
err = new Error("HTTP error " + response.statusCode);
|
||||
err.code = response.statusCode;
|
||||
callback(err);
|
||||
callback(err, response, body);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user