mirror of https://github.com/lukechilds/node.git
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
847 B
41 lines
847 B
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var http = require('http');
|
||
|
|
||
|
var expected = 'This is a unicode text: سلام';
|
||
|
var result = '';
|
||
|
|
||
|
var server = http.Server(function(req, res) {
|
||
|
req.setEncoding('utf8');
|
||
|
req.on('data', function(chunk) {
|
||
|
result += chunk;
|
||
|
}).on('end', function() {
|
||
|
clearTimeout(timeout);
|
||
|
server.close();
|
||
|
});
|
||
|
|
||
|
var timeout = setTimeout(function() {
|
||
|
process.exit(1);
|
||
|
}, 100);
|
||
|
|
||
|
res.writeHead(200);
|
||
|
res.end("hello world\n");
|
||
|
});
|
||
|
|
||
|
server.listen(common.PORT, function() {
|
||
|
http.request({
|
||
|
port: common.PORT,
|
||
|
path: '/',
|
||
|
method: 'POST'
|
||
|
}, function(res) {
|
||
|
console.log(res.statusCode);
|
||
|
}).on('error', function(e) {
|
||
|
console.log(e.message);
|
||
|
process.exit(1);
|
||
|
}).end(expected);
|
||
|
});
|
||
|
|
||
|
process.on('exit', function() {
|
||
|
assert.equal(expected, result);
|
||
|
});
|