diff --git a/lib/gzip.js b/lib/gzip.js index 7594bab..5e6edae 100644 --- a/lib/gzip.js +++ b/lib/gzip.js @@ -51,6 +51,7 @@ exports = module.exports = function gzip(options) { var args = Array.prototype.slice.call(arguments, 0), write = defaults.write, end = defaults.end, + version = process.versions.node.split('.'), headers, key, accept, type, encoding, gzip, ua; if (args.length > 1) { headers = args.pop(); @@ -93,7 +94,7 @@ exports = module.exports = function gzip(options) { write.call(res, chunk); }); - gzip.addListener('exit', function(code) { + gzip.addListener(version[0] === 0 && version[1] < 7 ? "exit" : "close", function(code) { res.write = write; res.end = end; res.end(); diff --git a/test/helpers/index.js b/test/helpers/index.js index 5ad1982..7f352a6 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -90,14 +90,16 @@ exports.testMaxAge = function(app, url, headers, maxAge) { function gunzip(data, callback) { var process = spawn('gunzip', ['-c']), out = '', - err = ''; + err = '', + version = process.versions.node.split('.'); + process.stdout.on('data', function(data) { out += data; }); process.stderr.on('data', function(data) { err += data; }); - process.on('exit', function(code) { + process.on(version[0] === 0 && version[1] < 7 ? "exit" : "close", function(code) { if (callback) callback(err, out); }); process.stdin.end(data, 'binary');