1 var common = require('../common');
2 var assert = require('assert');
3 var http = require('http');
7 var server = http.createServer(function(req, res) {
8 res.writeHead(200, {'Content-Type': 'text/plain'});
10 // write should accept string
12 // write should accept buffer
13 res.write(new Buffer('asdf'));
15 // write should not accept an Array
16 assert.throws(function() {
18 }, TypeError, 'first argument must be a string or Buffer');
20 // end should not accept an Array
21 assert.throws(function() {
23 }, TypeError, 'first argument must be a string or Buffer');
25 // end should accept string
27 } else if (test === 2) {
28 // end should accept Buffer
29 res.end(new Buffer('asdf'));
33 server.listen(common.PORT, function() {
34 // just make a request, other tests handle responses
35 http.get({port: common.PORT}, function(res) {
37 // lazy serial test, because we can only call end once per request
39 // do it again to test .end(Buffer);
40 http.get({port: common.PORT}, function(res) {