From 0b85fe29f7e49c88cab88aa9303d5885fa9c9dd5 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 8 Nov 2023 18:37:02 +0000 Subject: Tests: 8XXX used as default port range. After the launch of the project, the testing infrastructure was shared with nginx project in some cases. To avoid port overlap, a decision was made to shift the port range for Unit tests. This problem was resolved a long time ago and is no longer relevant, so it is now safe to use port 8XXX range as the default, as it is more appropriate for testing purposes. --- test/node/404/app.js | 2 +- test/node/basic/app.js | 2 +- test/node/double_end/app.js | 2 +- test/node/get_header_names/app.js | 2 +- test/node/get_header_type/app.js | 2 +- test/node/get_variables/app.js | 2 +- test/node/has_header/app.js | 2 +- test/node/header_name_case/app.js | 2 +- test/node/header_name_valid/app.js | 2 +- test/node/header_value_object/app.js | 2 +- test/node/loader/es_modules_http/app.mjs | 2 +- test/node/loader/es_modules_http_indirect/module.mjs | 2 +- test/node/loader/es_modules_websocket/app.mjs | 2 +- test/node/loader/es_modules_websocket_indirect/module.mjs | 2 +- test/node/loader/transitive_dependency/transitive_http.js | 2 +- test/node/loader/unit_http/app.js | 2 +- test/node/mirror/app.js | 2 +- test/node/post_variables/app.js | 2 +- test/node/promise_end/app.js | 2 +- test/node/promise_handler/app.js | 2 +- test/node/remove_header/app.js | 2 +- test/node/set_header_array/app.js | 2 +- test/node/status_message/app.js | 2 +- test/node/update_header/app.js | 2 +- test/node/variables/app.js | 2 +- test/node/websockets/mirror/app.js | 2 +- test/node/websockets/mirror_fragmentation/app.js | 2 +- test/node/write_array/app.js | 2 +- test/node/write_before_write_head/app.js | 2 +- test/node/write_buffer/app.js | 2 +- test/node/write_callback/app.js | 2 +- test/node/write_multiple/app.js | 2 +- test/node/write_return/app.js | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) (limited to 'test/node') diff --git a/test/node/404/app.js b/test/node/404/app.js index ba15c104..8beec34a 100644 --- a/test/node/404/app.js +++ b/test/node/404/app.js @@ -3,4 +3,4 @@ var fs = require('fs'); require('http').createServer(function (req, res) { res.writeHead(404, {}).end(fs.readFileSync('404.html')); -}).listen(7080); +}).listen(8080); diff --git a/test/node/basic/app.js b/test/node/basic/app.js index 9092022c..2d870003 100644 --- a/test/node/basic/app.js +++ b/test/node/basic/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); -}).listen(7080); +}).listen(8080); diff --git a/test/node/double_end/app.js b/test/node/double_end/app.js index 653e33b1..e721db77 100644 --- a/test/node/double_end/app.js +++ b/test/node/double_end/app.js @@ -1,4 +1,4 @@ require('http').createServer(function (req, res) { res.end().end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/get_header_names/app.js b/test/node/get_header_names/app.js index a938b762..77aa0327 100644 --- a/test/node/get_header_names/app.js +++ b/test/node/get_header_names/app.js @@ -4,4 +4,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Header', 'blah'); res.setHeader('X-Names', res.getHeaderNames()); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/get_header_type/app.js b/test/node/get_header_type/app.js index 6e45b71f..d5a591e8 100644 --- a/test/node/get_header_type/app.js +++ b/test/node/get_header_type/app.js @@ -3,4 +3,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Number', 100); res.setHeader('X-Type', typeof(res.getHeader('X-Number'))); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/get_variables/app.js b/test/node/get_variables/app.js index cded43d2..8f317cb4 100644 --- a/test/node/get_variables/app.js +++ b/test/node/get_variables/app.js @@ -5,4 +5,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Var-2', query.var2); res.setHeader('X-Var-3', query.var3); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/has_header/app.js b/test/node/has_header/app.js index 04b13916..30e75e4d 100644 --- a/test/node/has_header/app.js +++ b/test/node/has_header/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Has-Header', res.hasHeader(req.headers['x-header']) + ''); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/header_name_case/app.js b/test/node/header_name_case/app.js index af157547..45acd507 100644 --- a/test/node/header_name_case/app.js +++ b/test/node/header_name_case/app.js @@ -4,4 +4,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-header', '2'); res.setHeader('X-HEADER', '3'); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/header_name_valid/app.js b/test/node/header_name_valid/app.js index c0c36098..9ac0c3a2 100644 --- a/test/node/header_name_valid/app.js +++ b/test/node/header_name_valid/app.js @@ -3,4 +3,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {}); res.setHeader('@$', 'test'); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/header_value_object/app.js b/test/node/header_value_object/app.js index bacdc7d5..6f3d74bc 100644 --- a/test/node/header_value_object/app.js +++ b/test/node/header_value_object/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Header', {}); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/loader/es_modules_http/app.mjs b/test/node/loader/es_modules_http/app.mjs index c7bcfe49..28ff08d8 100644 --- a/test/node/loader/es_modules_http/app.mjs +++ b/test/node/loader/es_modules_http/app.mjs @@ -3,4 +3,4 @@ import http from "http" http.createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); -}).listen(7080); +}).listen(8080); diff --git a/test/node/loader/es_modules_http_indirect/module.mjs b/test/node/loader/es_modules_http_indirect/module.mjs index c7bcfe49..28ff08d8 100644 --- a/test/node/loader/es_modules_http_indirect/module.mjs +++ b/test/node/loader/es_modules_http_indirect/module.mjs @@ -3,4 +3,4 @@ import http from "http" http.createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); -}).listen(7080); +}).listen(8080); diff --git a/test/node/loader/es_modules_websocket/app.mjs b/test/node/loader/es_modules_websocket/app.mjs index a71ffa9d..361d855b 100644 --- a/test/node/loader/es_modules_websocket/app.mjs +++ b/test/node/loader/es_modules_websocket/app.mjs @@ -4,7 +4,7 @@ import websocket from "websocket" let server = http.createServer(function() {}); let webSocketServer = websocket.server; -server.listen(7080, function() {}); +server.listen(8080, function() {}); var wsServer = new webSocketServer({ maxReceivedMessageSize: 0x1000000000, diff --git a/test/node/loader/es_modules_websocket_indirect/module.mjs b/test/node/loader/es_modules_websocket_indirect/module.mjs index a71ffa9d..361d855b 100644 --- a/test/node/loader/es_modules_websocket_indirect/module.mjs +++ b/test/node/loader/es_modules_websocket_indirect/module.mjs @@ -4,7 +4,7 @@ import websocket from "websocket" let server = http.createServer(function() {}); let webSocketServer = websocket.server; -server.listen(7080, function() {}); +server.listen(8080, function() {}); var wsServer = new webSocketServer({ maxReceivedMessageSize: 0x1000000000, diff --git a/test/node/loader/transitive_dependency/transitive_http.js b/test/node/loader/transitive_dependency/transitive_http.js index f1eb98e5..171758ed 100644 --- a/test/node/loader/transitive_dependency/transitive_http.js +++ b/test/node/loader/transitive_dependency/transitive_http.js @@ -3,6 +3,6 @@ const http = require("http"); http.createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); -}).listen(7080); +}).listen(8080); module.exports = http; diff --git a/test/node/loader/unit_http/app.js b/test/node/loader/unit_http/app.js index 9172e44f..0e0c2b24 100644 --- a/test/node/loader/unit_http/app.js +++ b/test/node/loader/unit_http/app.js @@ -1,4 +1,4 @@ require("unit-http").createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); -}).listen(7080); +}).listen(8080); diff --git a/test/node/mirror/app.js b/test/node/mirror/app.js index bdefe1cd..bdb89489 100644 --- a/test/node/mirror/app.js +++ b/test/node/mirror/app.js @@ -8,4 +8,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Length': Buffer.byteLength(body)}) .end(body); }); -}).listen(7080); +}).listen(8080); diff --git a/test/node/post_variables/app.js b/test/node/post_variables/app.js index 12b867cb..4d88434d 100644 --- a/test/node/post_variables/app.js +++ b/test/node/post_variables/app.js @@ -11,4 +11,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Var-3', query.var3); res.end(); }); -}).listen(7080); +}).listen(8080); diff --git a/test/node/promise_end/app.js b/test/node/promise_end/app.js index 373c3bc6..75c2ef7d 100644 --- a/test/node/promise_end/app.js +++ b/test/node/promise_end/app.js @@ -12,4 +12,4 @@ require('http').createServer(function (req, res) { fs.appendFile('callback', '', function() {}); }); -}).listen(7080); +}).listen(8080); diff --git a/test/node/promise_handler/app.js b/test/node/promise_handler/app.js index 32d7d7b9..7bcb1ae9 100644 --- a/test/node/promise_handler/app.js +++ b/test/node/promise_handler/app.js @@ -13,4 +13,4 @@ require('http').createServer(function (req, res) { fs.appendFile(data.toString(), '', function() {}); }); }); -}).listen(7080); +}).listen(8080); diff --git a/test/node/remove_header/app.js b/test/node/remove_header/app.js index 2a591235..877a7351 100644 --- a/test/node/remove_header/app.js +++ b/test/node/remove_header/app.js @@ -7,4 +7,4 @@ require('http').createServer(function (req, res) { res.setHeader('Has-Header', res.hasHeader('X-Header').toString()); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/set_header_array/app.js b/test/node/set_header_array/app.js index 965330e2..0dee477e 100644 --- a/test/node/set_header_array/app.js +++ b/test/node/set_header_array/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.setHeader('Set-Cookie', ['tc=one,two,three', 'tc=four,five,six']); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/status_message/app.js b/test/node/status_message/app.js index ba51d35b..53eea5c7 100644 --- a/test/node/status_message/app.js +++ b/test/node/status_message/app.js @@ -1,4 +1,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, 'blah', {'Content-Type': 'text/plain'}).end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/update_header/app.js b/test/node/update_header/app.js index 905ac294..dc3415e6 100644 --- a/test/node/update_header/app.js +++ b/test/node/update_header/app.js @@ -3,4 +3,4 @@ require('http').createServer(function (req, res) { res.setHeader('X-Header', 'test'); res.setHeader('X-Header', 'new'); res.end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/variables/app.js b/test/node/variables/app.js index a569dddd..b6f36f37 100644 --- a/test/node/variables/app.js +++ b/test/node/variables/app.js @@ -15,4 +15,4 @@ require('http').createServer(function (req, res) { res.setHeader('Http-Host', req.headers['host']); res.writeHead(200, {}).end(body); }); -}).listen(7080); +}).listen(8080); diff --git a/test/node/websockets/mirror/app.js b/test/node/websockets/mirror/app.js index 0443adb2..ee2bdd18 100644 --- a/test/node/websockets/mirror/app.js +++ b/test/node/websockets/mirror/app.js @@ -2,7 +2,7 @@ server = require('http').createServer(function() {}); webSocketServer = require('websocket').server; -server.listen(7080, function() {}); +server.listen(8080, function() {}); var wsServer = new webSocketServer({ maxReceivedMessageSize: 0x1000000000, diff --git a/test/node/websockets/mirror_fragmentation/app.js b/test/node/websockets/mirror_fragmentation/app.js index ea580ac2..ca539ad6 100644 --- a/test/node/websockets/mirror_fragmentation/app.js +++ b/test/node/websockets/mirror_fragmentation/app.js @@ -2,7 +2,7 @@ server = require('http').createServer(function() {}); webSocketServer = require('websocket').server; -server.listen(7080, function() {}); +server.listen(8080, function() {}); var wsServer = new webSocketServer({ httpServer: server diff --git a/test/node/write_array/app.js b/test/node/write_array/app.js index b7abb3fc..761e8537 100644 --- a/test/node/write_array/app.js +++ b/test/node/write_array/app.js @@ -1,4 +1,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Length': 5, 'Content-Type': 'text/plain'}) .end(new Uint8Array(Buffer.from('array', 'utf8'))); -}).listen(7080); +}).listen(8080); diff --git a/test/node/write_before_write_head/app.js b/test/node/write_before_write_head/app.js index 2293111a..10c8b9d6 100644 --- a/test/node/write_before_write_head/app.js +++ b/test/node/write_before_write_head/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.write('blah'); res.writeHead(200, {'Content-Type': 'text/plain'}).end(); -}).listen(7080); +}).listen(8080); diff --git a/test/node/write_buffer/app.js b/test/node/write_buffer/app.js index 72e9c600..24585ef2 100644 --- a/test/node/write_buffer/app.js +++ b/test/node/write_buffer/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}) .end(Buffer.from('buffer', 'utf8')); -}).listen(7080); +}).listen(8080); diff --git a/test/node/write_callback/app.js b/test/node/write_callback/app.js index 71eb4116..f03cb213 100644 --- a/test/node/write_callback/app.js +++ b/test/node/write_callback/app.js @@ -9,4 +9,4 @@ require('http').createServer(function (req, res) { fs.appendFile('callback', '', function() {}); }); res.end(a); -}).listen(7080); +}).listen(8080); diff --git a/test/node/write_multiple/app.js b/test/node/write_multiple/app.js index e9c51ae0..b1e485e7 100644 --- a/test/node/write_multiple/app.js +++ b/test/node/write_multiple/app.js @@ -4,4 +4,4 @@ require('http').createServer(function (req, res) { res.write('write'); res.write('write2'); res.end('end'); -}).listen(7080); +}).listen(8080); diff --git a/test/node/write_return/app.js b/test/node/write_return/app.js index 345b6c4b..d0b3d850 100644 --- a/test/node/write_return/app.js +++ b/test/node/write_return/app.js @@ -2,4 +2,4 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}) .end(res.write('body').toString()); -}).listen(7080); +}).listen(8080); -- cgit From 1443d623d4b5d59e4463e025b4125be9a5aa3436 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Fri, 17 Nov 2023 17:27:31 +0000 Subject: Node.js: ServerResponse.flushHeaders() implemented. This closes #1006 issue on GitHub. Reviewed-by: Andrew Clayton --- test/node/flush_headers/app.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/node/flush_headers/app.js (limited to 'test/node') diff --git a/test/node/flush_headers/app.js b/test/node/flush_headers/app.js new file mode 100644 index 00000000..4c0e93bc --- /dev/null +++ b/test/node/flush_headers/app.js @@ -0,0 +1,7 @@ + +require('http').createServer(function (req, res) { + res.setHeader('X-Header', 'blah'); + res.flushHeaders(); + res.flushHeaders(); // Should be idempotent. + res.end(); +}).listen(8080); -- cgit From fbeb2065b180e2376088387ee150d3975dc08cd5 Mon Sep 17 00:00:00 2001 From: Gabor Javorszky Date: Wed, 14 Feb 2024 18:16:01 +0000 Subject: fix: Take options as well as requestListener (#1091) * Take options as well as requestListener Unit-http have not kept up with the signature of nodejs's http package development. Nodejs allows an optional `options` object to be passed to the `createServer` function, we didn't. This resulted in function signature errors when user code that did make use of the options arg tried to call unit's replaced function. This change changes the signature to be more in line with how nodejs does it discarding it and printing a message to stdout. * Add test file to start node application with options * Add changes to docs/changes.xml Closes: https://github.com/nginx/unit/issues/1043 --- test/node/options/app.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/node/options/app.js (limited to 'test/node') diff --git a/test/node/options/app.js b/test/node/options/app.js new file mode 100644 index 00000000..bc538080 --- /dev/null +++ b/test/node/options/app.js @@ -0,0 +1,4 @@ +require('http').createServer({}, function (req, res) { + res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) + .end('Hello World\n'); +}).listen(8080); -- cgit