Skip to content

Commit

Permalink
Ignore eresult 2 values from WebAPI if the response seems to be fine
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorMcKay committed Dec 14, 2017
1 parent aae32c6 commit 5cf8877
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
test.js
test*.js
.idea/
polldata.json
7 changes: 7 additions & 0 deletions lib/webapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ TradeOfferManager.prototype._apiCall = function(httpMethod, method, version, inp
}

var eresult = response.headers['x-eresult'];
if (eresult == 2 && body && (Object.keys(body).length > 1 || (body.response && Object.keys(body.response).length > 0))) {
// Steam has been known to send fake Fail (2) responses when it actually worked, because of course it has
// If we get a 2 but body is there and either body has more than one key or body.response exists and it has content,
// ignore the 2
eresult = 1;
}

if (typeof eresult !== 'undefined' && eresult != 1) {
var error = new Error(EResult[eresult] || eresult);
error.eresult = eresult;
Expand Down

0 comments on commit 5cf8877

Please sign in to comment.