mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
var fs = require('fs');
|
|
var util = require('util');
|
|
var path = require('path');
|
|
var fn = path.join(common.fixturesDir, 'does_not_exist.txt');
|
|
|
|
var got_error = false;
|
|
var conn_closed = false;
|
|
|
|
var server = net.createServer(function(stream) {
|
|
common.error('pump!');
|
|
util.pump(fs.createReadStream(fn), stream, function(err) {
|
|
common.error('util.pump\'s callback fired');
|
|
if (err) {
|
|
got_error = true;
|
|
} else {
|
|
common.debug('util.pump\'s callback fired with no error');
|
|
common.debug('this shouldn\'t happen as the file doesn\'t exist...');
|
|
assert.equal(true, false);
|
|
}
|
|
server.close();
|
|
});
|
|
});
|
|
|
|
server.listen(common.PORT, function() {
|
|
var conn = net.createConnection(common.PORT);
|
|
conn.setEncoding('utf8');
|
|
conn.on('data', function(chunk) {
|
|
common.error('recv data! nchars = ' + chunk.length);
|
|
buffer += chunk;
|
|
});
|
|
|
|
conn.on('end', function() {
|
|
conn.end();
|
|
});
|
|
|
|
conn.on('close', function() {
|
|
common.error('client connection close');
|
|
conn_closed = true;
|
|
});
|
|
});
|
|
|
|
var buffer = '';
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(true, got_error);
|
|
assert.equal(true, conn_closed);
|
|
console.log('exiting');
|
|
});
|