2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-01-13 21:42:45 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const net = require('net');
|
|
|
|
const http = require('http');
|
2010-01-27 18:34:45 +01:00
|
|
|
|
2010-08-11 02:37:30 +02:00
|
|
|
var server = net.createServer(function(socket) {
|
2010-04-08 19:44:22 +02:00
|
|
|
socket.end();
|
2010-01-27 18:34:45 +01:00
|
|
|
});
|
2011-01-21 03:19:30 +01:00
|
|
|
|
2016-07-15 21:43:24 +02:00
|
|
|
server.on('listening', common.mustCall(function() {
|
2010-08-11 02:37:30 +02:00
|
|
|
var client = http.createClient(common.PORT);
|
|
|
|
|
2016-07-15 21:43:24 +02:00
|
|
|
client.on('error', common.mustCall(function(err) {}));
|
|
|
|
client.on('end', common.mustCall(function() {}));
|
2010-08-11 02:37:30 +02:00
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
var request = client.request('GET', '/', {'host': 'localhost'});
|
2010-08-11 02:37:30 +02:00
|
|
|
request.end();
|
2011-10-15 01:08:36 +02:00
|
|
|
request.on('response', function(response) {
|
2010-12-03 02:03:18 +01:00
|
|
|
console.log('STATUS: ' + response.statusCode);
|
2010-08-11 02:37:30 +02:00
|
|
|
});
|
2016-07-15 21:43:24 +02:00
|
|
|
}));
|
2011-01-21 03:19:30 +01:00
|
|
|
|
2010-08-11 02:37:30 +02:00
|
|
|
server.listen(common.PORT);
|
2010-01-27 18:34:45 +01:00
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
setTimeout(function() {
|
2010-01-27 18:34:45 +01:00
|
|
|
server.close();
|
|
|
|
}, 500);
|