2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-15 15:43:24 -04:00
|
|
|
const common = require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const http = require('http');
|
2010-05-25 19:24:30 -07:00
|
|
|
|
2010-12-06 01:33:52 +03:00
|
|
|
var body = 'hello world\n';
|
2010-05-25 19:24:30 -07:00
|
|
|
|
2014-09-13 13:08:25 +01:00
|
|
|
function test(headers) {
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
console.error('req: %s headers: %j', req.method, headers);
|
|
|
|
res.writeHead(200, headers);
|
|
|
|
res.end();
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
server.listen(0, common.mustCall(function() {
|
2014-09-13 13:08:25 +01:00
|
|
|
var request = http.request({
|
2016-05-29 03:06:56 -04:00
|
|
|
port: this.address().port,
|
2014-09-13 13:08:25 +01:00
|
|
|
method: 'HEAD',
|
|
|
|
path: '/'
|
2016-07-15 15:43:24 -04:00
|
|
|
}, common.mustCall(function(response) {
|
2014-09-13 13:08:25 +01:00
|
|
|
console.error('response start');
|
2016-07-15 15:43:24 -04:00
|
|
|
response.on('end', common.mustCall(function() {
|
2014-09-13 13:08:25 +01:00
|
|
|
console.error('response end');
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2014-09-13 13:08:25 +01:00
|
|
|
response.resume();
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2014-09-13 13:08:25 +01:00
|
|
|
request.end();
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2014-09-13 13:08:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
test({
|
|
|
|
'Transfer-Encoding': 'chunked'
|
|
|
|
});
|
|
|
|
test({
|
|
|
|
'Content-Length': body.length
|
2010-05-25 19:24:30 -07:00
|
|
|
});
|