joyent/node — Issue #2162: http: res.end(array) triggers assert() in v0.6
Author: bnoordhuis
Created: 2011-11-22 12:50:34+00:00
State: open
Labels: http

Reported by Dave Irvine (davman in #node.js).

Test case:

```javascript
var assert = require('assert');
var http = require('http');

var gotError = false;

process.on('exit', function() {
assert.equal(gotError, true);
});

var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(['moo']); // send array, triggers assert
});

server.listen(8080, function() {
var req = http.get({host:'127.0.0.1', port:8080}, function(res) {
// do nothing
});

req.on('error', function(e) {
// expect parse error
assert.equal(e.message, 'Parse Error');
gotError = true;
server.close();
});
});
```

Passes with master, triggers an assert in v0.6.

```
node: ../src/stream_wrap.cc:289: static v8::Handle node::StreamWrap::Write(const v8::Arguments&): Assertion `Buffer::HasInstance(args[0])' failed.
Aborted
```

Side question: should `res.end(['foo'])` raise a TypeError or do something with the array?