blob: acce151b20af79c9516849323a2a99c68b355bd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
var common = require('../common');
var assert = require('assert');
var http = require('http');
var expect = 'hex\nutf8\n';
var data = '';
var ended = false;
process.on('exit', function() {
assert(ended);
assert.equal(data, expect);
console.log('ok');
});
http.createServer(function(q, s) {
s.setHeader('content-length', expect.length);
s.write('6865780a', 'hex');
s.write('utf8\n');
s.end();
this.close();
}).listen(common.PORT, function() {
http.request({ port: common.PORT }).on('response', function(res) {
res.setEncoding('ascii');
res.on('data', function(c) {
data += c;
});
res.on('end', function() {
ended = true;
});
}).end();
});
|