From f52711fe0aa0f7e4020478cebae743d973f86c42 Mon Sep 17 00:00:00 2001 From: d9k Date: Thu, 29 Jul 2021 12:47:06 +0300 Subject: [PATCH] #190 fix "Cannot read property 'headers' of undefined" --- lib/XMLHttpRequest.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/XMLHttpRequest.js b/lib/XMLHttpRequest.js index bada957..0f819f6 100644 --- a/lib/XMLHttpRequest.js +++ b/lib/XMLHttpRequest.js @@ -236,10 +236,12 @@ exports.XMLHttpRequest = function() { } var result = ""; - for (var i in response.headers) { + var headers = this.response.headers; + + for (var i in headers) { // Cookie headers are excluded if (i !== "set-cookie" && i !== "set-cookie2") { - result += i + ": " + response.headers[i] + "\r\n"; + result += i + ": " + headers[i] + "\r\n"; } } return result.substr(0, result.length - 2);