From a0c083af208cd9f676bb56762b4e27a3174a773d Mon Sep 17 00:00:00 2001 From: Oisin Canty Date: Wed, 12 May 2021 09:26:55 +0000 Subject: Node.js: a shim for overriding "http" and "websocket" modules. Also added stubs for Server.address() This was done to prevent crashes in some popular frameworks like express Supports both CommonJS and the new ES Modules system syntax e.g: app.js: const http = require('http') app.mjs: import http from "http" Usage on Node 14.16.x and higher: { "type": "external", "processes": {"spare": 0}, "working_directory": '/project', "executable": "/usr/bin/env", "arguments": [ "node", "--loader", "unit-http/require_shim.mjs" "--require", "unit-http/require_shim", "app.js" ] } Usage on Node 14.15.x and lower: { "type": "external", "processes": {"spare": 0}, "working_directory": '/project', "executable": "/usr/bin/env", "arguments": [ "node", "--require", "unit-http/require_shim", "app.js" ] } --- test/node/404/app.js | 3 +-- test/node/basic/app.js | 3 +-- test/node/double_end/app.js | 3 +-- test/node/get_header_names/app.js | 3 +-- test/node/get_header_type/app.js | 3 +-- test/node/get_variables/app.js | 3 +-- test/node/has_header/app.js | 3 +-- test/node/header_name_case/app.js | 3 +-- test/node/header_name_valid/app.js | 3 +-- test/node/header_value_object/app.js | 3 +-- test/node/mirror/app.js | 3 +-- test/node/post_variables/app.js | 3 +-- test/node/promise_end/app.js | 3 +-- test/node/promise_handler/app.js | 3 +-- test/node/remove_header/app.js | 3 +-- test/node/require_shim/es_modules_http/app.mjs | 6 +++++ .../require_shim/es_modules_http_indirect/app.js | 1 + .../es_modules_http_indirect/module.mjs | 6 +++++ .../node/require_shim/es_modules_websocket/app.mjs | 30 ++++++++++++++++++++++ .../es_modules_websocket_indirect/app.js | 1 + .../es_modules_websocket_indirect/module.mjs | 30 ++++++++++++++++++++++ .../node/require_shim/transitive_dependency/app.js | 1 + .../transitive_dependency/transitive_http.js | 8 ++++++ test/node/require_shim/unit_http/app.js | 4 +++ test/node/set_header_array/app.js | 3 +-- test/node/status_message/app.js | 3 +-- test/node/update_header/app.js | 3 +-- test/node/variables/app.js | 3 +-- test/node/websockets/mirror/app.js | 7 ++--- test/node/websockets/mirror_fragmentation/app.js | 7 ++--- test/node/write_before_write_head/app.js | 3 +-- test/node/write_buffer/app.js | 3 +-- test/node/write_callback/app.js | 3 +-- test/node/write_multiple/app.js | 3 +-- test/node/write_return/app.js | 3 +-- 35 files changed, 115 insertions(+), 58 deletions(-) mode change 100755 => 100644 test/node/404/app.js mode change 100755 => 100644 test/node/basic/app.js mode change 100755 => 100644 test/node/double_end/app.js mode change 100755 => 100644 test/node/get_header_names/app.js mode change 100755 => 100644 test/node/get_header_type/app.js mode change 100755 => 100644 test/node/get_variables/app.js mode change 100755 => 100644 test/node/has_header/app.js mode change 100755 => 100644 test/node/header_name_case/app.js mode change 100755 => 100644 test/node/header_name_valid/app.js mode change 100755 => 100644 test/node/header_value_object/app.js mode change 100755 => 100644 test/node/mirror/app.js mode change 100755 => 100644 test/node/post_variables/app.js mode change 100755 => 100644 test/node/promise_end/app.js mode change 100755 => 100644 test/node/promise_handler/app.js mode change 100755 => 100644 test/node/remove_header/app.js create mode 100644 test/node/require_shim/es_modules_http/app.mjs create mode 100644 test/node/require_shim/es_modules_http_indirect/app.js create mode 100644 test/node/require_shim/es_modules_http_indirect/module.mjs create mode 100644 test/node/require_shim/es_modules_websocket/app.mjs create mode 100644 test/node/require_shim/es_modules_websocket_indirect/app.js create mode 100644 test/node/require_shim/es_modules_websocket_indirect/module.mjs create mode 100644 test/node/require_shim/transitive_dependency/app.js create mode 100644 test/node/require_shim/transitive_dependency/transitive_http.js create mode 100644 test/node/require_shim/unit_http/app.js mode change 100755 => 100644 test/node/set_header_array/app.js mode change 100755 => 100644 test/node/status_message/app.js mode change 100755 => 100644 test/node/update_header/app.js mode change 100755 => 100644 test/node/variables/app.js mode change 100755 => 100644 test/node/websockets/mirror/app.js mode change 100755 => 100644 test/node/websockets/mirror_fragmentation/app.js mode change 100755 => 100644 test/node/write_before_write_head/app.js mode change 100755 => 100644 test/node/write_buffer/app.js mode change 100755 => 100644 test/node/write_callback/app.js mode change 100755 => 100644 test/node/write_multiple/app.js mode change 100755 => 100644 test/node/write_return/app.js (limited to 'test/node') diff --git a/test/node/404/app.js b/test/node/404/app.js old mode 100755 new mode 100644 index 587c432d..ba15c104 --- a/test/node/404/app.js +++ b/test/node/404/app.js @@ -1,7 +1,6 @@ -#!/usr/bin/env node var fs = require('fs'); -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(404, {}).end(fs.readFileSync('404.html')); }).listen(7080); diff --git a/test/node/basic/app.js b/test/node/basic/app.js old mode 100755 new mode 100644 index 7820c474..9092022c --- a/test/node/basic/app.js +++ b/test/node/basic/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) .end('Hello World\n'); }).listen(7080); diff --git a/test/node/double_end/app.js b/test/node/double_end/app.js old mode 100755 new mode 100644 index 63912097..653e33b1 --- a/test/node/double_end/app.js +++ b/test/node/double_end/app.js @@ -1,5 +1,4 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.end().end(); }).listen(7080); diff --git a/test/node/get_header_names/app.js b/test/node/get_header_names/app.js old mode 100755 new mode 100644 index 4cbccc16..a938b762 --- a/test/node/get_header_names/app.js +++ b/test/node/get_header_names/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('DATE', ['date1', 'date2']); res.setHeader('X-Header', 'blah'); res.setHeader('X-Names', res.getHeaderNames()); diff --git a/test/node/get_header_type/app.js b/test/node/get_header_type/app.js old mode 100755 new mode 100644 index b606f142..6e45b71f --- a/test/node/get_header_type/app.js +++ b/test/node/get_header_type/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Number', 100); res.setHeader('X-Type', typeof(res.getHeader('X-Number'))); res.end(); diff --git a/test/node/get_variables/app.js b/test/node/get_variables/app.js old mode 100755 new mode 100644 index 5c1faf41..cded43d2 --- a/test/node/get_variables/app.js +++ b/test/node/get_variables/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { let query = require('url').parse(req.url, true).query; res.setHeader('X-Var-1', query.var1); res.setHeader('X-Var-2', query.var2); diff --git a/test/node/has_header/app.js b/test/node/has_header/app.js old mode 100755 new mode 100644 index eff7f4ff..04b13916 --- a/test/node/has_header/app.js +++ b/test/node/has_header/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Has-Header', res.hasHeader(req.headers['x-header']) + ''); res.end(); }).listen(7080); diff --git a/test/node/header_name_case/app.js b/test/node/header_name_case/app.js old mode 100755 new mode 100644 index 490bd4d5..af157547 --- a/test/node/header_name_case/app.js +++ b/test/node/header_name_case/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Header', '1'); res.setHeader('X-header', '2'); res.setHeader('X-HEADER', '3'); diff --git a/test/node/header_name_valid/app.js b/test/node/header_name_valid/app.js old mode 100755 new mode 100644 index 425f026f..c0c36098 --- a/test/node/header_name_valid/app.js +++ b/test/node/header_name_valid/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {}); res.setHeader('@$', 'test'); res.end(); diff --git a/test/node/header_value_object/app.js b/test/node/header_value_object/app.js old mode 100755 new mode 100644 index ff4e2bb0..bacdc7d5 --- a/test/node/header_value_object/app.js +++ b/test/node/header_value_object/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Header', {}); res.end(); }).listen(7080); diff --git a/test/node/mirror/app.js b/test/node/mirror/app.js old mode 100755 new mode 100644 index 1488917e..bdefe1cd --- a/test/node/mirror/app.js +++ b/test/node/mirror/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { let body = ''; req.on('data', chunk => { body += chunk.toString(); diff --git a/test/node/post_variables/app.js b/test/node/post_variables/app.js old mode 100755 new mode 100644 index 928a38cf..12b867cb --- a/test/node/post_variables/app.js +++ b/test/node/post_variables/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { let body = ''; req.on('data', chunk => { body += chunk.toString(); diff --git a/test/node/promise_end/app.js b/test/node/promise_end/app.js old mode 100755 new mode 100644 index ed22464c..373c3bc6 --- a/test/node/promise_end/app.js +++ b/test/node/promise_end/app.js @@ -1,8 +1,7 @@ -#!/usr/bin/env node var fs = require('fs'); -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.write('blah'); Promise.resolve().then(() => { diff --git a/test/node/promise_handler/app.js b/test/node/promise_handler/app.js old mode 100755 new mode 100644 index 51c3666b..32d7d7b9 --- a/test/node/promise_handler/app.js +++ b/test/node/promise_handler/app.js @@ -1,8 +1,7 @@ -#!/usr/bin/env node var fs = require('fs'); -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.end(); if (req.headers['x-write-call']) { diff --git a/test/node/remove_header/app.js b/test/node/remove_header/app.js old mode 100755 new mode 100644 index cd7b80c3..2a591235 --- a/test/node/remove_header/app.js +++ b/test/node/remove_header/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Header', 'test'); res.setHeader('Was-Header', res.hasHeader('X-Header').toString()); diff --git a/test/node/require_shim/es_modules_http/app.mjs b/test/node/require_shim/es_modules_http/app.mjs new file mode 100644 index 00000000..c7bcfe49 --- /dev/null +++ b/test/node/require_shim/es_modules_http/app.mjs @@ -0,0 +1,6 @@ +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); diff --git a/test/node/require_shim/es_modules_http_indirect/app.js b/test/node/require_shim/es_modules_http_indirect/app.js new file mode 100644 index 00000000..535befba --- /dev/null +++ b/test/node/require_shim/es_modules_http_indirect/app.js @@ -0,0 +1 @@ +import("./module.mjs") diff --git a/test/node/require_shim/es_modules_http_indirect/module.mjs b/test/node/require_shim/es_modules_http_indirect/module.mjs new file mode 100644 index 00000000..c7bcfe49 --- /dev/null +++ b/test/node/require_shim/es_modules_http_indirect/module.mjs @@ -0,0 +1,6 @@ +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); diff --git a/test/node/require_shim/es_modules_websocket/app.mjs b/test/node/require_shim/es_modules_websocket/app.mjs new file mode 100644 index 00000000..a71ffa9d --- /dev/null +++ b/test/node/require_shim/es_modules_websocket/app.mjs @@ -0,0 +1,30 @@ +import http from "http" +import websocket from "websocket" + +let server = http.createServer(function() {}); +let webSocketServer = websocket.server; + +server.listen(7080, function() {}); + +var wsServer = new webSocketServer({ + maxReceivedMessageSize: 0x1000000000, + maxReceivedFrameSize: 0x1000000000, + fragmentOutgoingMessages: false, + fragmentationThreshold: 0x1000000000, + httpServer: server, +}); + +wsServer.on('request', function(request) { + var connection = request.accept(null); + + connection.on('message', function(message) { + if (message.type === 'utf8') { + connection.send(message.utf8Data); + } else if (message.type === 'binary') { + connection.send(message.binaryData); + } + + }); + + connection.on('close', function(r) {}); +}); diff --git a/test/node/require_shim/es_modules_websocket_indirect/app.js b/test/node/require_shim/es_modules_websocket_indirect/app.js new file mode 100644 index 00000000..535befba --- /dev/null +++ b/test/node/require_shim/es_modules_websocket_indirect/app.js @@ -0,0 +1 @@ +import("./module.mjs") diff --git a/test/node/require_shim/es_modules_websocket_indirect/module.mjs b/test/node/require_shim/es_modules_websocket_indirect/module.mjs new file mode 100644 index 00000000..a71ffa9d --- /dev/null +++ b/test/node/require_shim/es_modules_websocket_indirect/module.mjs @@ -0,0 +1,30 @@ +import http from "http" +import websocket from "websocket" + +let server = http.createServer(function() {}); +let webSocketServer = websocket.server; + +server.listen(7080, function() {}); + +var wsServer = new webSocketServer({ + maxReceivedMessageSize: 0x1000000000, + maxReceivedFrameSize: 0x1000000000, + fragmentOutgoingMessages: false, + fragmentationThreshold: 0x1000000000, + httpServer: server, +}); + +wsServer.on('request', function(request) { + var connection = request.accept(null); + + connection.on('message', function(message) { + if (message.type === 'utf8') { + connection.send(message.utf8Data); + } else if (message.type === 'binary') { + connection.send(message.binaryData); + } + + }); + + connection.on('close', function(r) {}); +}); diff --git a/test/node/require_shim/transitive_dependency/app.js b/test/node/require_shim/transitive_dependency/app.js new file mode 100644 index 00000000..aaca5216 --- /dev/null +++ b/test/node/require_shim/transitive_dependency/app.js @@ -0,0 +1 @@ +require("./transitive_http") diff --git a/test/node/require_shim/transitive_dependency/transitive_http.js b/test/node/require_shim/transitive_dependency/transitive_http.js new file mode 100644 index 00000000..f1eb98e5 --- /dev/null +++ b/test/node/require_shim/transitive_dependency/transitive_http.js @@ -0,0 +1,8 @@ +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); + +module.exports = http; diff --git a/test/node/require_shim/unit_http/app.js b/test/node/require_shim/unit_http/app.js new file mode 100644 index 00000000..9172e44f --- /dev/null +++ b/test/node/require_shim/unit_http/app.js @@ -0,0 +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); diff --git a/test/node/set_header_array/app.js b/test/node/set_header_array/app.js old mode 100755 new mode 100644 index faac45c7..965330e2 --- a/test/node/set_header_array/app.js +++ b/test/node/set_header_array/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('Set-Cookie', ['tc=one,two,three', 'tc=four,five,six']); res.end(); }).listen(7080); diff --git a/test/node/status_message/app.js b/test/node/status_message/app.js old mode 100755 new mode 100644 index e8a798dd..ba51d35b --- a/test/node/status_message/app.js +++ b/test/node/status_message/app.js @@ -1,5 +1,4 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, 'blah', {'Content-Type': 'text/plain'}).end(); }).listen(7080); diff --git a/test/node/update_header/app.js b/test/node/update_header/app.js old mode 100755 new mode 100644 index 0c5cd237..905ac294 --- a/test/node/update_header/app.js +++ b/test/node/update_header/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.setHeader('X-Header', 'test'); res.setHeader('X-Header', 'new'); res.end(); diff --git a/test/node/variables/app.js b/test/node/variables/app.js old mode 100755 new mode 100644 index d8cdc20c..a569dddd --- a/test/node/variables/app.js +++ b/test/node/variables/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { let body = ''; req.on('data', chunk => { body += chunk.toString(); diff --git a/test/node/websockets/mirror/app.js b/test/node/websockets/mirror/app.js old mode 100755 new mode 100644 index 23746465..0443adb2 --- a/test/node/websockets/mirror/app.js +++ b/test/node/websockets/mirror/app.js @@ -1,9 +1,6 @@ -#!/usr/bin/env node -server = require('unit-http').createServer(function() {}); -webSocketServer = require('unit-http/websocket').server; -//server = require('http').createServer(function() {}); -//webSocketServer = require('websocket').server; +server = require('http').createServer(function() {}); +webSocketServer = require('websocket').server; server.listen(7080, function() {}); diff --git a/test/node/websockets/mirror_fragmentation/app.js b/test/node/websockets/mirror_fragmentation/app.js old mode 100755 new mode 100644 index 7024252a..ea580ac2 --- a/test/node/websockets/mirror_fragmentation/app.js +++ b/test/node/websockets/mirror_fragmentation/app.js @@ -1,9 +1,6 @@ -#!/usr/bin/env node -server = require('unit-http').createServer(function() {}); -webSocketServer = require('unit-http/websocket').server; -//server = require('http').createServer(function() {}); -//webSocketServer = require('websocket').server; +server = require('http').createServer(function() {}); +webSocketServer = require('websocket').server; server.listen(7080, function() {}); diff --git a/test/node/write_before_write_head/app.js b/test/node/write_before_write_head/app.js old mode 100755 new mode 100644 index 724b0efb..2293111a --- a/test/node/write_before_write_head/app.js +++ b/test/node/write_before_write_head/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.write('blah'); res.writeHead(200, {'Content-Type': 'text/plain'}).end(); }).listen(7080); diff --git a/test/node/write_buffer/app.js b/test/node/write_buffer/app.js old mode 100755 new mode 100644 index a7623523..506e8613 --- a/test/node/write_buffer/app.js +++ b/test/node/write_buffer/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}) .end(new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72])); }).listen(7080); diff --git a/test/node/write_callback/app.js b/test/node/write_callback/app.js old mode 100755 new mode 100644 index 3a9e51e8..71eb4116 --- a/test/node/write_callback/app.js +++ b/test/node/write_callback/app.js @@ -1,8 +1,7 @@ -#!/usr/bin/env node var fs = require('fs'); -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); var a = 'world'; res.write('hello', 'utf8', function() { diff --git a/test/node/write_multiple/app.js b/test/node/write_multiple/app.js old mode 100755 new mode 100644 index 3cbb3b86..e9c51ae0 --- a/test/node/write_multiple/app.js +++ b/test/node/write_multiple/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain', 'Content-Length': 14}); res.write('write'); res.write('write2'); diff --git a/test/node/write_return/app.js b/test/node/write_return/app.js old mode 100755 new mode 100644 index 82dfbc6e..345b6c4b --- a/test/node/write_return/app.js +++ b/test/node/write_return/app.js @@ -1,6 +1,5 @@ -#!/usr/bin/env node -require('unit-http').createServer(function (req, res) { +require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}) .end(res.write('body').toString()); }).listen(7080); -- cgit From c160ea11e4ece4db52731ac8b83dd09ca2d1ef11 Mon Sep 17 00:00:00 2001 From: Oisin Canty Date: Mon, 24 May 2021 09:01:42 +0000 Subject: Node.js: renamed "require_shim" to "loader". --- test/node/loader/es_modules_http/app.mjs | 6 +++++ test/node/loader/es_modules_http_indirect/app.js | 1 + .../loader/es_modules_http_indirect/module.mjs | 6 +++++ test/node/loader/es_modules_websocket/app.mjs | 30 ++++++++++++++++++++++ .../loader/es_modules_websocket_indirect/app.js | 1 + .../es_modules_websocket_indirect/module.mjs | 30 ++++++++++++++++++++++ test/node/loader/transitive_dependency/app.js | 1 + .../transitive_dependency/transitive_http.js | 8 ++++++ test/node/loader/unit_http/app.js | 4 +++ test/node/require_shim/es_modules_http/app.mjs | 6 ----- .../require_shim/es_modules_http_indirect/app.js | 1 - .../es_modules_http_indirect/module.mjs | 6 ----- .../node/require_shim/es_modules_websocket/app.mjs | 30 ---------------------- .../es_modules_websocket_indirect/app.js | 1 - .../es_modules_websocket_indirect/module.mjs | 30 ---------------------- .../node/require_shim/transitive_dependency/app.js | 1 - .../transitive_dependency/transitive_http.js | 8 ------ test/node/require_shim/unit_http/app.js | 4 --- 18 files changed, 87 insertions(+), 87 deletions(-) create mode 100644 test/node/loader/es_modules_http/app.mjs create mode 100644 test/node/loader/es_modules_http_indirect/app.js create mode 100644 test/node/loader/es_modules_http_indirect/module.mjs create mode 100644 test/node/loader/es_modules_websocket/app.mjs create mode 100644 test/node/loader/es_modules_websocket_indirect/app.js create mode 100644 test/node/loader/es_modules_websocket_indirect/module.mjs create mode 100644 test/node/loader/transitive_dependency/app.js create mode 100644 test/node/loader/transitive_dependency/transitive_http.js create mode 100644 test/node/loader/unit_http/app.js delete mode 100644 test/node/require_shim/es_modules_http/app.mjs delete mode 100644 test/node/require_shim/es_modules_http_indirect/app.js delete mode 100644 test/node/require_shim/es_modules_http_indirect/module.mjs delete mode 100644 test/node/require_shim/es_modules_websocket/app.mjs delete mode 100644 test/node/require_shim/es_modules_websocket_indirect/app.js delete mode 100644 test/node/require_shim/es_modules_websocket_indirect/module.mjs delete mode 100644 test/node/require_shim/transitive_dependency/app.js delete mode 100644 test/node/require_shim/transitive_dependency/transitive_http.js delete mode 100644 test/node/require_shim/unit_http/app.js (limited to 'test/node') diff --git a/test/node/loader/es_modules_http/app.mjs b/test/node/loader/es_modules_http/app.mjs new file mode 100644 index 00000000..c7bcfe49 --- /dev/null +++ b/test/node/loader/es_modules_http/app.mjs @@ -0,0 +1,6 @@ +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); diff --git a/test/node/loader/es_modules_http_indirect/app.js b/test/node/loader/es_modules_http_indirect/app.js new file mode 100644 index 00000000..535befba --- /dev/null +++ b/test/node/loader/es_modules_http_indirect/app.js @@ -0,0 +1 @@ +import("./module.mjs") diff --git a/test/node/loader/es_modules_http_indirect/module.mjs b/test/node/loader/es_modules_http_indirect/module.mjs new file mode 100644 index 00000000..c7bcfe49 --- /dev/null +++ b/test/node/loader/es_modules_http_indirect/module.mjs @@ -0,0 +1,6 @@ +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); diff --git a/test/node/loader/es_modules_websocket/app.mjs b/test/node/loader/es_modules_websocket/app.mjs new file mode 100644 index 00000000..a71ffa9d --- /dev/null +++ b/test/node/loader/es_modules_websocket/app.mjs @@ -0,0 +1,30 @@ +import http from "http" +import websocket from "websocket" + +let server = http.createServer(function() {}); +let webSocketServer = websocket.server; + +server.listen(7080, function() {}); + +var wsServer = new webSocketServer({ + maxReceivedMessageSize: 0x1000000000, + maxReceivedFrameSize: 0x1000000000, + fragmentOutgoingMessages: false, + fragmentationThreshold: 0x1000000000, + httpServer: server, +}); + +wsServer.on('request', function(request) { + var connection = request.accept(null); + + connection.on('message', function(message) { + if (message.type === 'utf8') { + connection.send(message.utf8Data); + } else if (message.type === 'binary') { + connection.send(message.binaryData); + } + + }); + + connection.on('close', function(r) {}); +}); diff --git a/test/node/loader/es_modules_websocket_indirect/app.js b/test/node/loader/es_modules_websocket_indirect/app.js new file mode 100644 index 00000000..535befba --- /dev/null +++ b/test/node/loader/es_modules_websocket_indirect/app.js @@ -0,0 +1 @@ +import("./module.mjs") diff --git a/test/node/loader/es_modules_websocket_indirect/module.mjs b/test/node/loader/es_modules_websocket_indirect/module.mjs new file mode 100644 index 00000000..a71ffa9d --- /dev/null +++ b/test/node/loader/es_modules_websocket_indirect/module.mjs @@ -0,0 +1,30 @@ +import http from "http" +import websocket from "websocket" + +let server = http.createServer(function() {}); +let webSocketServer = websocket.server; + +server.listen(7080, function() {}); + +var wsServer = new webSocketServer({ + maxReceivedMessageSize: 0x1000000000, + maxReceivedFrameSize: 0x1000000000, + fragmentOutgoingMessages: false, + fragmentationThreshold: 0x1000000000, + httpServer: server, +}); + +wsServer.on('request', function(request) { + var connection = request.accept(null); + + connection.on('message', function(message) { + if (message.type === 'utf8') { + connection.send(message.utf8Data); + } else if (message.type === 'binary') { + connection.send(message.binaryData); + } + + }); + + connection.on('close', function(r) {}); +}); diff --git a/test/node/loader/transitive_dependency/app.js b/test/node/loader/transitive_dependency/app.js new file mode 100644 index 00000000..aaca5216 --- /dev/null +++ b/test/node/loader/transitive_dependency/app.js @@ -0,0 +1 @@ +require("./transitive_http") diff --git a/test/node/loader/transitive_dependency/transitive_http.js b/test/node/loader/transitive_dependency/transitive_http.js new file mode 100644 index 00000000..f1eb98e5 --- /dev/null +++ b/test/node/loader/transitive_dependency/transitive_http.js @@ -0,0 +1,8 @@ +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); + +module.exports = http; diff --git a/test/node/loader/unit_http/app.js b/test/node/loader/unit_http/app.js new file mode 100644 index 00000000..9172e44f --- /dev/null +++ b/test/node/loader/unit_http/app.js @@ -0,0 +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); diff --git a/test/node/require_shim/es_modules_http/app.mjs b/test/node/require_shim/es_modules_http/app.mjs deleted file mode 100644 index c7bcfe49..00000000 --- a/test/node/require_shim/es_modules_http/app.mjs +++ /dev/null @@ -1,6 +0,0 @@ -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); diff --git a/test/node/require_shim/es_modules_http_indirect/app.js b/test/node/require_shim/es_modules_http_indirect/app.js deleted file mode 100644 index 535befba..00000000 --- a/test/node/require_shim/es_modules_http_indirect/app.js +++ /dev/null @@ -1 +0,0 @@ -import("./module.mjs") diff --git a/test/node/require_shim/es_modules_http_indirect/module.mjs b/test/node/require_shim/es_modules_http_indirect/module.mjs deleted file mode 100644 index c7bcfe49..00000000 --- a/test/node/require_shim/es_modules_http_indirect/module.mjs +++ /dev/null @@ -1,6 +0,0 @@ -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); diff --git a/test/node/require_shim/es_modules_websocket/app.mjs b/test/node/require_shim/es_modules_websocket/app.mjs deleted file mode 100644 index a71ffa9d..00000000 --- a/test/node/require_shim/es_modules_websocket/app.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import http from "http" -import websocket from "websocket" - -let server = http.createServer(function() {}); -let webSocketServer = websocket.server; - -server.listen(7080, function() {}); - -var wsServer = new webSocketServer({ - maxReceivedMessageSize: 0x1000000000, - maxReceivedFrameSize: 0x1000000000, - fragmentOutgoingMessages: false, - fragmentationThreshold: 0x1000000000, - httpServer: server, -}); - -wsServer.on('request', function(request) { - var connection = request.accept(null); - - connection.on('message', function(message) { - if (message.type === 'utf8') { - connection.send(message.utf8Data); - } else if (message.type === 'binary') { - connection.send(message.binaryData); - } - - }); - - connection.on('close', function(r) {}); -}); diff --git a/test/node/require_shim/es_modules_websocket_indirect/app.js b/test/node/require_shim/es_modules_websocket_indirect/app.js deleted file mode 100644 index 535befba..00000000 --- a/test/node/require_shim/es_modules_websocket_indirect/app.js +++ /dev/null @@ -1 +0,0 @@ -import("./module.mjs") diff --git a/test/node/require_shim/es_modules_websocket_indirect/module.mjs b/test/node/require_shim/es_modules_websocket_indirect/module.mjs deleted file mode 100644 index a71ffa9d..00000000 --- a/test/node/require_shim/es_modules_websocket_indirect/module.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import http from "http" -import websocket from "websocket" - -let server = http.createServer(function() {}); -let webSocketServer = websocket.server; - -server.listen(7080, function() {}); - -var wsServer = new webSocketServer({ - maxReceivedMessageSize: 0x1000000000, - maxReceivedFrameSize: 0x1000000000, - fragmentOutgoingMessages: false, - fragmentationThreshold: 0x1000000000, - httpServer: server, -}); - -wsServer.on('request', function(request) { - var connection = request.accept(null); - - connection.on('message', function(message) { - if (message.type === 'utf8') { - connection.send(message.utf8Data); - } else if (message.type === 'binary') { - connection.send(message.binaryData); - } - - }); - - connection.on('close', function(r) {}); -}); diff --git a/test/node/require_shim/transitive_dependency/app.js b/test/node/require_shim/transitive_dependency/app.js deleted file mode 100644 index aaca5216..00000000 --- a/test/node/require_shim/transitive_dependency/app.js +++ /dev/null @@ -1 +0,0 @@ -require("./transitive_http") diff --git a/test/node/require_shim/transitive_dependency/transitive_http.js b/test/node/require_shim/transitive_dependency/transitive_http.js deleted file mode 100644 index f1eb98e5..00000000 --- a/test/node/require_shim/transitive_dependency/transitive_http.js +++ /dev/null @@ -1,8 +0,0 @@ -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); - -module.exports = http; diff --git a/test/node/require_shim/unit_http/app.js b/test/node/require_shim/unit_http/app.js deleted file mode 100644 index 9172e44f..00000000 --- a/test/node/require_shim/unit_http/app.js +++ /dev/null @@ -1,4 +0,0 @@ -require("unit-http").createServer(function (req, res) { - res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) - .end('Hello World\n'); -}).listen(7080); -- cgit