blob: 2310a6f83162f3f24e18bd2207e39fc7e269038c (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
var common = require('../common');
var assert = require('assert');
var http = require('http');
var util = require('util');
var body = 'hello world\n';
var id = 0;
function test(headers) {
var port = common.PORT + id++;
var server = http.createServer(function(req, res) {
console.error('req: %s headers: %j', req.method, headers);
res.writeHead(200, headers);
res.end();
server.close();
});
var gotEnd = false;
server.listen(port, function() {
var request = http.request({
port: port,
method: 'HEAD',
path: '/'
}, function(response) {
console.error('response start');
response.on('end', function() {
console.error('response end');
gotEnd = true;
});
response.resume();
});
request.end();
});
process.on('exit', function() {
assert.ok(gotEnd);
});
}
test({
'Transfer-Encoding': 'chunked'
});
test({
'Content-Length': body.length
});
|