node-XMLHttpRequest icon indicating copy to clipboard operation
node-XMLHttpRequest copied to clipboard

Synchronous requests: xhr.status corrupted with responseText

Open aldohb opened this issue 12 years ago • 1 comments

OS version: OS X 10.8.4 Node.js version: v.0.10.5 and v.0.10.17 XHR Module version: 1.5.0

When using XHR to do a synchronous request, the status field gets corrupted with the full responseText body.

xhr.open('GET', url, false);
xhr.send();

console.log("startsWith(xhr.status, 200)? " + startsWith(xhr.status, 200));
console.log("xhr.status == 200? " + (xhr.status ==  200));
console.log("Value of status: " + xhr.status);

Output:

startsWith(xhr.status, 200)? true
xhr.status == 200? false
Value of status: 200 "id": "index", "version": "1.0", [more JSON follows]

It would appear that the regex that does the text replacement in lines 463 and 464 of lib/XMLHttpRequest.js is broken.

aldohb avatar Sep 03 '13 21:09 aldohb

Just ran into this exact issue, what a disaster.

~~Gonna try and fix it and submit a pull request.~~

There is a pull request waiting to be merged that fixes this issue (that I did not write). Please merge it in.

Rybadour avatar Jan 08 '15 15:01 Rybadour