You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.0 KiB

var common = require('../common');
var assert = require('assert');
var assert = require('assert');
var http = require('http');
var util = require('util');
var body = 'hello world';
var server = http.createServer(function(req, res) {
res.writeHeader(200,
{'Content-Length': body.length.toString(),
'Content-Type': 'text/plain'
});
console.log('method: ' + req.method);
if (req.method != 'HEAD') res.write(body);
res.end();
});
server.listen(common.PORT);
var gotEnd = false;
server.addListener('listening', function() {
var client = http.createClient(common.PORT);
var request = client.request('HEAD', '/');
request.addListener('response', function(response) {
console.log('got response');
response.addListener('data', function() {
process.exit(2);
});
response.addListener('end', function() {
process.exit(0);
});
});
request.end();
});
//give a bit of time for the server to respond before we check it
setTimeout(function() {
process.exit(1);
}, 2000);