driverdan/node-XMLHttpRequest — pull request #57 by tomhughes (2013-07-14 16:40:02+00:00)
Title: Fix issues in test-request-protocols

The `test-request-protocols` test was failing for me because `tests/testdata.txt` had a trailing newline that the assertion was not expecting:

```
AssertionError: "Hello World" == "Hello World\n"
at xhr.onreadystatechange (/home/tom/src/nodejs/node-XMLHttpRequest/tests/test-request-protocols.js:10:12)
at dispatchEvent (/home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:570:25)
at setState (/home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:589:14)
at /home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:304:13
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
```

Once I fixed that it was still failing because the `onreadystatechange` callbacks try and call `this.close()` but the XHR object doesn't have a `close` method:

```
TypeError: Object [object Object] has no method 'close'
at xhr.onreadystatechange (/home/tom/src/nodejs/node-XMLHttpRequest/tests/test-request-protocols.js:11:10)
at dispatchEvent (/home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:570:25)
at setState (/home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:589:14)
at /home/tom/src/nodejs/node-XMLHttpRequest/lib/XMLHttpRequest.js:304:13
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
```