From 5cf887782cf96299395a40a6470d2afac2f1065d Mon Sep 17 00:00:00 2001 From: Alexander Corn Date: Thu, 14 Dec 2017 16:19:07 -0500 Subject: [PATCH] Ignore eresult 2 values from WebAPI if the response seems to be fine --- .gitignore | 1 + lib/webapi.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index f2f7c37..340f46e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ test.js +test*.js .idea/ polldata.json diff --git a/lib/webapi.js b/lib/webapi.js index 50af2a6..daddcbe 100644 --- a/lib/webapi.js +++ b/lib/webapi.js @@ -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;