2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var http = require('http');
|
|
|
|
var util = require('util');
|
2010-05-26 10:24:30 +08:00
|
|
|
|
|
|
|
|
2010-12-05 07:20:34 +08:00
|
|
|
var body = "hello world\n";
|
2010-05-26 10:24:30 +08:00
|
|
|
|
2010-12-05 07:20:34 +08:00
|
|
|
var server = http.createServer(function (req, res) {
|
2010-07-16 02:47:25 +08:00
|
|
|
common.error('req: ' + req.method);
|
2010-05-26 10:24:30 +08:00
|
|
|
res.writeHead(200, {"Content-Length": body.length});
|
|
|
|
res.end();
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
var gotEnd = false;
|
|
|
|
|
2010-07-16 02:47:25 +08:00
|
|
|
server.listen(common.PORT, function () {
|
|
|
|
var client = http.createClient(common.PORT);
|
2010-05-26 10:24:30 +08:00
|
|
|
var request = client.request("HEAD", "/");
|
2010-06-21 02:54:51 +08:00
|
|
|
request.end();
|
2010-05-26 10:24:30 +08:00
|
|
|
request.addListener('response', function (response) {
|
2010-07-16 02:47:25 +08:00
|
|
|
common.error('response start');
|
2010-05-26 10:24:30 +08:00
|
|
|
response.addListener("end", function () {
|
2010-07-16 02:47:25 +08:00
|
|
|
common.error('response end');
|
2010-05-26 10:24:30 +08:00
|
|
|
gotEnd = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
process.addListener('exit', function () {
|
|
|
|
assert.ok(gotEnd);
|
|
|
|
});
|