diff --git a/tests/server/index.js b/tests/server/index.js index 9c6e6bf9..1ef29fe4 100644 --- a/tests/server/index.js +++ b/tests/server/index.js @@ -1,6 +1,6 @@ const http = require('http'); const stringify = require('json-stringify-safe'); -const Busboy = require('busboy'); +const busboy = require('busboy'); const { Iconv } = require('iconv'); const port = process.env.PORT || 5000; @@ -15,9 +15,10 @@ function parseMultipartForm (req, res, finishCb) { const fields = {}; const files = {}; - const busboy = new Busboy({ headers: req.headers }); + const bb = busboy({ headers: req.headers }); - busboy.on('file', function (fieldname, file, filename, encoding, mimetype) { + bb.on('file', (name, file, info) => { + const { filename } = info; const currentFile = { size: 0 }; file.on('data', function (data) { @@ -25,16 +26,16 @@ function parseMultipartForm (req, res, finishCb) { currentFile.size += data.length; }); - file.on('end', function () { + file.on('close', function () { files.file = currentFile; }); }); - busboy.on('field', function (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) { + bb.on('field', function (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) { fields[fieldname] = val; }); - busboy.on('finish', function () { + bb.on('close', function () { console.log(stringify({ fields, files })); // This is needed due to this bug: https://github.com/mscdex/busboy/issues/73 @@ -43,7 +44,7 @@ function parseMultipartForm (req, res, finishCb) { } }); - busboy.on('error', function (err) { + bb.on('error', function (err) { console.error(`error: ${err}: ${JSON.stringify(err)}`); errorOccured = true; @@ -51,7 +52,7 @@ function parseMultipartForm (req, res, finishCb) { res.end(`Could not parse multipart form: ${err}\n`); }); - req.pipe(busboy); + req.pipe(bb); } function respondWithParsedForm (req, res, parseResultObj) { @@ -115,7 +116,7 @@ http.createServer(function (req, res) { req.on('data', function (chunk) { body += chunk; if (body.length > DIRECT_UPLOAD_LIMIT) { - req.connection.destroy(); + req.socket.destroy(); } }); @@ -150,7 +151,7 @@ http.createServer(function (req, res) { res.end('404\n'); } - console.log(req.connection.remoteAddress + ' ' + req.method + ' ' + req.url + ' ' + res.statusCode + ' ' + req.headers['user-agent']); + console.log(req.socket.remoteAddress + ' ' + req.method + ' ' + req.url + ' ' + res.statusCode + ' ' + req.headers['user-agent']); }).listen(port, '0.0.0.0'); console.log('Server running on ' + port); diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index 5abb38e9..43128f17 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "busboy": "^0.3.1", + "busboy": "^1.6.0", "forever": "^4.0.3", "iconv": "^3.0.1", "json-stringify-safe": "^5.0.1" @@ -290,14 +290,14 @@ } }, "node_modules/busboy": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", - "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "dependencies": { - "dicer": "0.3.0" + "streamsearch": "^1.1.0" }, "engines": { - "node": ">=4.5.0" + "node": ">=10.16.0" } }, "node_modules/cache-base": { @@ -684,17 +684,6 @@ "node": ">=0.10.0" } }, - "node_modules/dicer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", - "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", - "dependencies": { - "streamsearch": "0.1.2" - }, - "engines": { - "node": ">=4.5.0" - } - }, "node_modules/director": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/director/-/director-1.2.7.tgz", @@ -2170,6 +2159,15 @@ "node": ">=4" } }, + "node_modules/pkginfo": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", + "integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ==", + "extraneous": true, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -2748,11 +2746,11 @@ } }, "node_modules/streamsearch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "integrity": "sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", "engines": { - "node": ">=0.8.0" + "node": ">=10.0.0" } }, "node_modules/string_decoder": { @@ -3330,11 +3328,11 @@ } }, "busboy": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", - "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "requires": { - "dicer": "0.3.0" + "streamsearch": "^1.1.0" } }, "cache-base": { @@ -3653,14 +3651,6 @@ "isobject": "^3.0.1" } }, - "dicer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", - "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", - "requires": { - "streamsearch": "0.1.2" - } - }, "director": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/director/-/director-1.2.7.tgz", @@ -4785,6 +4775,11 @@ "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==" }, + "pkginfo": { + "version": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", + "integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ==", + "extraneous": true + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -5243,9 +5238,9 @@ } }, "streamsearch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "integrity": "sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" }, "string_decoder": { "version": "1.1.1", diff --git a/tests/server/package.json b/tests/server/package.json index a55f920d..b5f40573 100644 --- a/tests/server/package.json +++ b/tests/server/package.json @@ -15,7 +15,7 @@ "author": "Apache Software Foundation", "license": "Apache-2.0", "dependencies": { - "busboy": "^0.3.1", + "busboy": "^1.6.0", "forever": "^4.0.3", "iconv": "^3.0.1", "json-stringify-safe": "^5.0.1"