ultimate-express 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/package.json +10 -6
- package/src/request.js +1 -1
- package/src/router.js +9 -3
- package/src/utils.js +5 -2
- package/.github/workflows/test.yml +0 -27
- package/tests/index.js +0 -64
- package/tests/parts/.test/index.html +0 -11
- package/tests/parts/big.jpg +0 -0
- package/tests/parts/index.art +0 -12
- package/tests/parts/index.dot +0 -12
- package/tests/parts/index.ejs +0 -12
- package/tests/parts/index.handlebars +0 -2
- package/tests/parts/index.html +0 -12
- package/tests/parts/index.mustache +0 -12
- package/tests/parts/index.pug +0 -6
- package/tests/parts/index.swig +0 -12
- package/tests/parts/layouts/main.handlebars +0 -12
- package/tests/preload.cjs +0 -5
- package/tests/singular.js +0 -41
- package/tests/tests/app/app-engine.js +0 -8
- package/tests/tests/app/app-on-mount.js +0 -24
- package/tests/tests/app/app-path.js +0 -21
- package/tests/tests/app/app-route.js +0 -30
- package/tests/tests/app/options.js +0 -16
- package/tests/tests/app/setting-inheritance.js +0 -16
- package/tests/tests/engines/art-template.js +0 -33
- package/tests/tests/engines/dot.js +0 -28
- package/tests/tests/engines/ejs.js +0 -25
- package/tests/tests/engines/handlebars.js +0 -28
- package/tests/tests/engines/mustache.js +0 -28
- package/tests/tests/engines/pug.js +0 -25
- package/tests/tests/engines/swig.js +0 -28
- package/tests/tests/errors/error-handling-middleware.js +0 -22
- package/tests/tests/errors/next-error-optimized.js +0 -26
- package/tests/tests/errors/next-error.js +0 -26
- package/tests/tests/errors/unexpected-error-handling.js +0 -18
- package/tests/tests/listen/listen-random.js +0 -11
- package/tests/tests/listen/listen-specific.js +0 -17
- package/tests/tests/middlewares/body-json.js +0 -31
- package/tests/tests/middlewares/body-raw-deflate.js +0 -43
- package/tests/tests/middlewares/body-raw-gzip.js +0 -43
- package/tests/tests/middlewares/body-raw.js +0 -41
- package/tests/tests/middlewares/body-text.js +0 -27
- package/tests/tests/middlewares/body-urlencoded.js +0 -30
- package/tests/tests/middlewares/cookie-parser-signed.js +0 -31
- package/tests/tests/middlewares/cookie-parser.js +0 -28
- package/tests/tests/middlewares/cookie-session.js +0 -40
- package/tests/tests/middlewares/cors.js +0 -29
- package/tests/tests/middlewares/errorhandler.js +0 -26
- package/tests/tests/middlewares/express-fileupload-temp.js +0 -46
- package/tests/tests/middlewares/express-fileupload.js +0 -28
- package/tests/tests/middlewares/express-rate-limit.js +0 -33
- package/tests/tests/middlewares/express-session.js +0 -37
- package/tests/tests/middlewares/express-static-options.js +0 -72
- package/tests/tests/middlewares/express-static.js +0 -40
- package/tests/tests/middlewares/method-override.js +0 -33
- package/tests/tests/middlewares/multer.js +0 -43
- package/tests/tests/middlewares/multiple-middlewares.js +0 -37
- package/tests/tests/middlewares/response-time.js +0 -29
- package/tests/tests/middlewares/serve-index.js +0 -38
- package/tests/tests/middlewares/serve-static.js +0 -38
- package/tests/tests/middlewares/vhost.js +0 -50
- package/tests/tests/params/array-param.js +0 -30
- package/tests/tests/params/nested-params.js +0 -24
- package/tests/tests/params/param-errors.js +0 -56
- package/tests/tests/params/param-function.js +0 -49
- package/tests/tests/params/param-next-route.js +0 -48
- package/tests/tests/params/param-optimized.js +0 -38
- package/tests/tests/params/param-use.js +0 -39
- package/tests/tests/params/param.js +0 -68
- package/tests/tests/params/params-regex.js +0 -26
- package/tests/tests/params/params-use.js +0 -20
- package/tests/tests/params/params.js +0 -35
- package/tests/tests/req/req-accepts-charsets.js +0 -40
- package/tests/tests/req/req-accepts-encodings.js +0 -36
- package/tests/tests/req/req-accepts-languages.js +0 -41
- package/tests/tests/req/req-accepts.js +0 -41
- package/tests/tests/req/req-app.js +0 -17
- package/tests/tests/req/req-baseurl.js +0 -38
- package/tests/tests/req/req-connection.js +0 -19
- package/tests/tests/req/req-fresh.js +0 -59
- package/tests/tests/req/req-get.js +0 -78
- package/tests/tests/req/req-headers-distinct.js +0 -72
- package/tests/tests/req/req-headers.js +0 -72
- package/tests/tests/req/req-host.js +0 -45
- package/tests/tests/req/req-hostname.js +0 -45
- package/tests/tests/req/req-ip.js +0 -19
- package/tests/tests/req/req-is.js +0 -44
- package/tests/tests/req/req-original-url.js +0 -29
- package/tests/tests/req/req-param.js +0 -29
- package/tests/tests/req/req-protocol.js +0 -20
- package/tests/tests/req/req-query.js +0 -23
- package/tests/tests/req/req-range.js +0 -48
- package/tests/tests/req/req-raw-headers.js +0 -72
- package/tests/tests/req/req-subdomains.js +0 -48
- package/tests/tests/req/req-url-nested.js +0 -27
- package/tests/tests/req/req-url-optimized-router.js +0 -26
- package/tests/tests/req/req-url-optimized.js +0 -23
- package/tests/tests/req/req-url.js +0 -36
- package/tests/tests/req/req-xhr.js +0 -23
- package/tests/tests/res/head-content-length.js +0 -18
- package/tests/tests/res/head.js +0 -47
- package/tests/tests/res/injecting.js +0 -25
- package/tests/tests/res/piping.js +0 -23
- package/tests/tests/res/res-app.js +0 -17
- package/tests/tests/res/res-append.js +0 -24
- package/tests/tests/res/res-attachment.js +0 -19
- package/tests/tests/res/res-clear-cookie.js +0 -18
- package/tests/tests/res/res-cookie.js +0 -22
- package/tests/tests/res/res-download.js +0 -36
- package/tests/tests/res/res-format.js +0 -57
- package/tests/tests/res/res-get.js +0 -18
- package/tests/tests/res/res-headers-sent.js +0 -18
- package/tests/tests/res/res-json.js +0 -17
- package/tests/tests/res/res-jsonp.js +0 -25
- package/tests/tests/res/res-links.js +0 -21
- package/tests/tests/res/res-location.js +0 -34
- package/tests/tests/res/res-redirect.js +0 -46
- package/tests/tests/res/res-remove-header.js +0 -19
- package/tests/tests/res/res-send-file.js +0 -17
- package/tests/tests/res/res-send-status.js +0 -17
- package/tests/tests/res/res-send.js +0 -69
- package/tests/tests/res/res-set.js +0 -28
- package/tests/tests/res/res-status.js +0 -18
- package/tests/tests/res/res-type.js +0 -19
- package/tests/tests/res/res-vary.js +0 -19
- package/tests/tests/res/res-write.js +0 -29
- package/tests/tests/routers/complex-routers.js +0 -34
- package/tests/tests/routers/empty-router.js +0 -25
- package/tests/tests/routers/lot-of-routes.js +0 -38
- package/tests/tests/routers/mergeparams.js +0 -42
- package/tests/tests/routers/nested-routers.js +0 -52
- package/tests/tests/routers/router-options.js +0 -68
- package/tests/tests/routers/routers.js +0 -45
- package/tests/tests/routers/simple-routers.js +0 -35
- package/tests/tests/routing/all.js +0 -47
- package/tests/tests/routing/array-arguments.js +0 -35
- package/tests/tests/routing/array-use.js +0 -33
- package/tests/tests/routing/async-use.js +0 -25
- package/tests/tests/routing/complex-routes.js +0 -50
- package/tests/tests/routing/lot-of-param-routes.js +0 -26
- package/tests/tests/routing/lot-of-routes.js +0 -59
- package/tests/tests/routing/next-existent-optimized-route.js +0 -29
- package/tests/tests/routing/next-existent-route.js +0 -29
- package/tests/tests/routing/next-nonexistent-optimized-route.js +0 -19
- package/tests/tests/routing/next-nonexistent-route.js +0 -19
- package/tests/tests/routing/next-special-cases.js +0 -54
- package/tests/tests/routing/next-unoptimized.js +0 -39
- package/tests/tests/routing/no-path-use.js +0 -29
- package/tests/tests/routing/non-string-routes.js +0 -27
- package/tests/tests/routing/req-multiple-mountpaths.js +0 -34
- package/tests/tests/routing/simple-routes.js +0 -29
- package/tests/tests/routing/simple-use.js +0 -52
- package/tests/tests/routing/some-middlewares.js +0 -27
- package/tests/tests/routing/special-characters.js +0 -28
- package/tests/tests/routing/star.js +0 -31
- package/tests/tests/routing/sub-apps.js +0 -32
- package/tests/tests/routing/trailing-slash.js +0 -37
- package/tests/tests/routing/weird-route-start.js +0 -18
- package/tests/tests/send-file/accept-ranges.js +0 -26
- package/tests/tests/send-file/callback.js +0 -23
- package/tests/tests/send-file/default-error-routing.js +0 -21
- package/tests/tests/send-file/dotfiles.js +0 -24
- package/tests/tests/send-file/etag.js +0 -19
- package/tests/tests/send-file/fs-threads.js +0 -39
- package/tests/tests/send-file/head.js +0 -49
- package/tests/tests/send-file/headers.js +0 -23
- package/tests/tests/send-file/if-match.js +0 -31
- package/tests/tests/send-file/if-range.js +0 -37
- package/tests/tests/send-file/if-unmodified-since.js +0 -32
- package/tests/tests/send-file/immutable.js +0 -22
- package/tests/tests/send-file/large-file.js +0 -19
- package/tests/tests/send-file/last-modified.js +0 -21
- package/tests/tests/send-file/max-age.js +0 -21
- package/tests/tests/send-file/path-traversal.js +0 -35
- package/tests/tests/send-file/range.js +0 -57
- package/tests/tests/send-file/simple.js +0 -18
- package/tests/tests/settings/case-sensitive-routing.js +0 -48
- package/tests/tests/settings/env-errors.js +0 -38
- package/tests/tests/settings/etag.js +0 -36
- package/tests/tests/settings/json-escape.js +0 -45
- package/tests/tests/settings/json-replacer.js +0 -50
- package/tests/tests/settings/json-spaces.js +0 -44
- package/tests/tests/settings/query-parser.js +0 -45
- package/tests/tests/settings/strict-routing.js +0 -64
- package/tests/tests/settings/subdomain-offset.js +0 -38
- package/tests/tests/settings/trust-proxy-host.js +0 -58
- package/tests/tests/settings/trust-proxy-ip.js +0 -58
- package/tests/tests/settings/trust-proxy-ips.js +0 -58
- package/tests/tests/settings/trust-proxy-protocol.js +0 -46
- package/tests/tests/settings/x-powered-by.js +0 -32
- package/tests/uws.js +0 -14
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// must support "json replacer"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
app2.set('json replacer', (key, value) => {
|
|
8
|
-
if(typeof value === 'object' && value !== null) {
|
|
9
|
-
return 'REPLACED';
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
});
|
|
13
|
-
app.get('/abc', (req, res) => {
|
|
14
|
-
res.json({ test: { test: 1 } });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app2.get('/def', (req, res) => {
|
|
18
|
-
res.jsonp({ test: { test: 1 } });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
app2.get('/abc', (req, res) => {
|
|
22
|
-
res.json({ test: { test: 1 } });
|
|
23
|
-
});
|
|
24
|
-
app2.get('/def', (req, res) => {
|
|
25
|
-
res.jsonp({ test: { test: 1 } });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.listen(13333, async () => {
|
|
29
|
-
console.log('Server is running on port 13333');
|
|
30
|
-
|
|
31
|
-
let outputs = await Promise.all([
|
|
32
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13333/def').then(res => res.text()),
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
console.log(outputs.join(' '));
|
|
37
|
-
|
|
38
|
-
app2.listen(13334, async () => {
|
|
39
|
-
console.log('Server is running on port 13334');
|
|
40
|
-
|
|
41
|
-
let outputs2 = await Promise.all([
|
|
42
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
43
|
-
fetch('http://localhost:13334/def').then(res => res.text()),
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
console.log(outputs2.join(' '));
|
|
47
|
-
process.exit(0);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// must support "json spaces"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
app2.set('json spaces', 2);
|
|
8
|
-
app.get('/abc', (req, res) => {
|
|
9
|
-
res.json({ test: { test: 1 } });
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.get('/def', (req, res) => {
|
|
13
|
-
res.jsonp({ test: { test: 1 } });
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
app2.get('/abc', (req, res) => {
|
|
17
|
-
res.json({ test: { test: 1 } });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
app2.get('/def', (req, res) => {
|
|
21
|
-
res.jsonp({ test: { test: 1 } });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
app.listen(13333, async () => {
|
|
25
|
-
console.log('Server is running on port 13333');
|
|
26
|
-
|
|
27
|
-
let outputs = await Promise.all([
|
|
28
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
console.log(outputs.join(' '));
|
|
32
|
-
|
|
33
|
-
app2.listen(13334, async () => {
|
|
34
|
-
console.log('Server is running on port 13334');
|
|
35
|
-
|
|
36
|
-
let outputs2 = await Promise.all([
|
|
37
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
console.log(outputs2.join(' '));
|
|
41
|
-
process.exit(0);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// must support "query parser"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
const app3 = express();
|
|
8
|
-
const app4 = express();
|
|
9
|
-
|
|
10
|
-
app.set('query parser', false);
|
|
11
|
-
app2.set('query parser', 'simple');
|
|
12
|
-
app3.set('query parser', 'extended');
|
|
13
|
-
app4.set('query parser', query => {
|
|
14
|
-
return {hi: 'there'};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app.get('/abc', (req, res) => {
|
|
18
|
-
res.json(req.query);
|
|
19
|
-
});
|
|
20
|
-
app2.get('/abc', (req, res) => {
|
|
21
|
-
res.json(req.query);
|
|
22
|
-
});
|
|
23
|
-
app3.get('/abc', (req, res) => {
|
|
24
|
-
res.json(req.query);
|
|
25
|
-
});
|
|
26
|
-
app4.get('/abc', (req, res) => {
|
|
27
|
-
res.json(req.query);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
app.listen(13333, async () => {
|
|
31
|
-
app2.listen(13334, async () => {
|
|
32
|
-
app3.listen(13335, async () => {
|
|
33
|
-
app4.listen(13336, async () => {
|
|
34
|
-
let outputs = await Promise.all([
|
|
35
|
-
fetch('http://localhost:13333/abc?test=123').then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13334/abc?test=123').then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13335/abc?test=123').then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13336/abc?test=123').then(res => res.text()),
|
|
39
|
-
]);
|
|
40
|
-
console.log(outputs.join(' '));
|
|
41
|
-
process.exit(0);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// must support "strict routing"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
app.set('strict routing', true);
|
|
8
|
-
app2.set('strict routing', false);
|
|
9
|
-
|
|
10
|
-
app.get("/test/:test/", (req, res) => {
|
|
11
|
-
res.send('test');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app.get('/abc/', (req, res) => {
|
|
15
|
-
res.send('bye');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.get('/abc', (req, res) => {
|
|
19
|
-
res.send('hi');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
app2.get('/abc/', (req, res) => {
|
|
23
|
-
res.send('bye2');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
app2.get('/abc', (req, res) => {
|
|
27
|
-
res.send('hi2');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
app2.use((req, res, next) => {
|
|
31
|
-
res.send('404');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
app.use((req, res, next) => {
|
|
35
|
-
res.send('404');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
app.listen(13333, async () => {
|
|
39
|
-
|
|
40
|
-
console.log('Server is running on port 13333');
|
|
41
|
-
|
|
42
|
-
let outputs = await Promise.all([
|
|
43
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/abc/').then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13333/test/test/').then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13333/test/test').then(res => res.text()),
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log(outputs.join(' '));
|
|
51
|
-
|
|
52
|
-
app2.listen(13334, async () => {
|
|
53
|
-
console.log('Server is running on port 13334');
|
|
54
|
-
|
|
55
|
-
let outputs2 = await Promise.all([
|
|
56
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
57
|
-
fetch('http://localhost:13334/abc/').then(res => res.text()),
|
|
58
|
-
]);
|
|
59
|
-
|
|
60
|
-
console.log(outputs2.join(' '));
|
|
61
|
-
process.exit(0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// must support "subdomain offset"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
app.set('subdomain offset', 0);
|
|
8
|
-
app2.set('subdomain offset', 1);
|
|
9
|
-
|
|
10
|
-
app.get('/abc', (req, res) => {
|
|
11
|
-
res.send(req.subdomains.join('.'));
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app2.get('/abc', (req, res) => {
|
|
15
|
-
res.send(req.subdomains.join('.'));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
console.log('Server is running on port 13333');
|
|
20
|
-
|
|
21
|
-
let outputs = await Promise.all([
|
|
22
|
-
fetch('http://localhost:13333/abc').then(res => res.text())
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
console.log(outputs.join(' '));
|
|
26
|
-
|
|
27
|
-
app2.listen(13334, async () => {
|
|
28
|
-
console.log('Server is running on port 13334');
|
|
29
|
-
|
|
30
|
-
let outputs2 = await Promise.all([
|
|
31
|
-
fetch('http://localhost:13334/abc').then(res => res.text())
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
console.log(outputs2.join(' '));
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// must support "trust proxy" hosts
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
const app3 = express();
|
|
8
|
-
const app4 = express();
|
|
9
|
-
app.set('trust proxy', true);
|
|
10
|
-
app2.set('trust proxy', false);
|
|
11
|
-
app3.set('trust proxy', 'loopback');
|
|
12
|
-
app4.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
|
13
|
-
|
|
14
|
-
app.get('/abc', (req, res) => {
|
|
15
|
-
res.send(req.hostname);
|
|
16
|
-
});
|
|
17
|
-
app2.get('/abc', (req, res) => {
|
|
18
|
-
res.send(req.hostname);
|
|
19
|
-
});
|
|
20
|
-
app3.get('/abc', (req, res) => {
|
|
21
|
-
res.send(req.hostname);
|
|
22
|
-
});
|
|
23
|
-
app4.get('/abc', (req, res) => {
|
|
24
|
-
res.send(req.hostname);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
app2.listen(13334, async () => {
|
|
29
|
-
app3.listen(13335, async () => {
|
|
30
|
-
app4.listen(13336, async () => {
|
|
31
|
-
let outputs = await Promise.all([
|
|
32
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Host': '127.0.0.1' } }).then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Host': '127.0.0.1' } }).then(res => res.text()),
|
|
34
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Host': '127.0.0.1' } }).then(res => res.text()),
|
|
35
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Host': '127.0.0.1' } }).then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Host': '192.168.1.1' } }).then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Host': '192.168.1.1' } }).then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Host': '192.168.1.1' } }).then(res => res.text()),
|
|
39
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Host': '192.168.1.1' } }).then(res => res.text()),
|
|
40
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Host': '10.0.0.1' } }).then(res => res.text()),
|
|
41
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Host': '10.0.0.1' } }).then(res => res.text()),
|
|
42
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Host': '10.0.0.1' } }).then(res => res.text()),
|
|
43
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Host': '10.0.0.1' } }).then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Host': '172.16.0.1' } }).then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Host': '172.16.0.1' } }).then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Host': '172.16.0.1' } }).then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Host': '172.16.0.1' } }).then(res => res.text()),
|
|
48
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
49
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
50
|
-
fetch('http://localhost:13335/abc').then(res => res.text()),
|
|
51
|
-
fetch('http://localhost:13336/abc').then(res => res.text()),
|
|
52
|
-
]);
|
|
53
|
-
console.log(outputs.join(' ').replaceAll('0000:0000:0000:0000:0000:0000:0000:000', "::"));
|
|
54
|
-
process.exit(0);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// must support "trust proxy" ip
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
const app3 = express();
|
|
8
|
-
const app4 = express();
|
|
9
|
-
app.set('trust proxy', true);
|
|
10
|
-
app2.set('trust proxy', false);
|
|
11
|
-
app3.set('trust proxy', 'loopback');
|
|
12
|
-
app4.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
|
13
|
-
|
|
14
|
-
app.get('/abc', (req, res) => {
|
|
15
|
-
res.send(req.ip);
|
|
16
|
-
});
|
|
17
|
-
app2.get('/abc', (req, res) => {
|
|
18
|
-
res.send(req.ip);
|
|
19
|
-
});
|
|
20
|
-
app3.get('/abc', (req, res) => {
|
|
21
|
-
res.send(req.ip);
|
|
22
|
-
});
|
|
23
|
-
app4.get('/abc', (req, res) => {
|
|
24
|
-
res.send(req.ip);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
app2.listen(13334, async () => {
|
|
29
|
-
app3.listen(13335, async () => {
|
|
30
|
-
app4.listen(13336, async () => {
|
|
31
|
-
let outputs = await Promise.all([
|
|
32
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
34
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
35
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
39
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
40
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
41
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
42
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
43
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
48
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
49
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
50
|
-
fetch('http://localhost:13335/abc').then(res => res.text()),
|
|
51
|
-
fetch('http://localhost:13336/abc').then(res => res.text()),
|
|
52
|
-
]);
|
|
53
|
-
console.log(outputs.join(' ').replaceAll('0000:0000:0000:0000:0000:0000:0000:000', "::"));
|
|
54
|
-
process.exit(0);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// must support "trust proxy" ips
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
const app3 = express();
|
|
8
|
-
const app4 = express();
|
|
9
|
-
app.set('trust proxy', true);
|
|
10
|
-
app2.set('trust proxy', false);
|
|
11
|
-
app3.set('trust proxy', 'loopback');
|
|
12
|
-
app4.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
|
13
|
-
|
|
14
|
-
app.get('/abc', (req, res) => {
|
|
15
|
-
res.send(req.ips);
|
|
16
|
-
});
|
|
17
|
-
app2.get('/abc', (req, res) => {
|
|
18
|
-
res.send(req.ips);
|
|
19
|
-
});
|
|
20
|
-
app3.get('/abc', (req, res) => {
|
|
21
|
-
res.send(req.ips);
|
|
22
|
-
});
|
|
23
|
-
app4.get('/abc', (req, res) => {
|
|
24
|
-
res.send(req.ips);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
app2.listen(13334, async () => {
|
|
29
|
-
app3.listen(13335, async () => {
|
|
30
|
-
app4.listen(13336, async () => {
|
|
31
|
-
let outputs = await Promise.all([
|
|
32
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
34
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
35
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '127.0.0.1' } }).then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
39
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '192.168.1.1' } }).then(res => res.text()),
|
|
40
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
41
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
42
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
43
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '10.0.0.1' } }).then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-For': '172.16.0.1' } }).then(res => res.text()),
|
|
48
|
-
fetch('http://localhost:13333/abc').then(res => res.text()),
|
|
49
|
-
fetch('http://localhost:13334/abc').then(res => res.text()),
|
|
50
|
-
fetch('http://localhost:13335/abc').then(res => res.text()),
|
|
51
|
-
fetch('http://localhost:13336/abc').then(res => res.text()),
|
|
52
|
-
]);
|
|
53
|
-
console.log(outputs.join(' ').replaceAll('0000:0000:0000:0000:0000:0000:0000:000', "::"));
|
|
54
|
-
process.exit(0);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// must support "trust proxy" protocol
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
const app3 = express();
|
|
8
|
-
const app4 = express();
|
|
9
|
-
app.set('trust proxy', true);
|
|
10
|
-
app2.set('trust proxy', false);
|
|
11
|
-
app3.set('trust proxy', 'loopback');
|
|
12
|
-
app4.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
|
13
|
-
|
|
14
|
-
app.get('/abc', (req, res) => {
|
|
15
|
-
res.send(req.protocol);
|
|
16
|
-
});
|
|
17
|
-
app2.get('/abc', (req, res) => {
|
|
18
|
-
res.send(req.protocol);
|
|
19
|
-
});
|
|
20
|
-
app3.get('/abc', (req, res) => {
|
|
21
|
-
res.send(req.protocol);
|
|
22
|
-
});
|
|
23
|
-
app4.get('/abc', (req, res) => {
|
|
24
|
-
res.send(req.protocol);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
app2.listen(13334, async () => {
|
|
29
|
-
app3.listen(13335, async () => {
|
|
30
|
-
app4.listen(13336, async () => {
|
|
31
|
-
let outputs = await Promise.all([
|
|
32
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Proto': 'https' } }).then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Proto': 'https' } }).then(res => res.text()),
|
|
34
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Proto': 'https' } }).then(res => res.text()),
|
|
35
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Proto': 'https' } }).then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13333/abc', { headers: { 'X-Forwarded-Proto': 'http' } }).then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13334/abc', { headers: { 'X-Forwarded-Proto': 'http' } }).then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13335/abc', { headers: { 'X-Forwarded-Proto': 'http' } }).then(res => res.text()),
|
|
39
|
-
fetch('http://localhost:13336/abc', { headers: { 'X-Forwarded-Proto': 'http' } }).then(res => res.text()),
|
|
40
|
-
]);
|
|
41
|
-
console.log(outputs.join(' '));
|
|
42
|
-
process.exit(0);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// must support "x-powered-by"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const app2 = express();
|
|
7
|
-
app.set('x-powered-by', true);
|
|
8
|
-
app2.set('x-powered-by', false);
|
|
9
|
-
|
|
10
|
-
app.get('/abc', (req, res) => {
|
|
11
|
-
res.send('ok');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app2.get('/abc', (req, res) => {
|
|
15
|
-
res.send('ok');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
app2.listen(13334, async () => {
|
|
20
|
-
|
|
21
|
-
let outputs = await Promise.all([
|
|
22
|
-
fetch('http://localhost:13333/abc').then(res => res.headers.get('x-powered-by')),
|
|
23
|
-
fetch('http://localhost:13334/abc').then(res => res.headers.get('x-powered-by')),
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
console.log(outputs.map(output => {
|
|
27
|
-
console.log(typeof output);
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
process.exit(0);
|
|
31
|
-
});
|
|
32
|
-
});
|
package/tests/uws.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const uWS = require("uWebSockets.js");
|
|
2
|
-
|
|
3
|
-
const app = uWS.App();
|
|
4
|
-
|
|
5
|
-
app.get('/', (res, req) => {
|
|
6
|
-
res.cork(() => {
|
|
7
|
-
res.write('Hello World');
|
|
8
|
-
res.end();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
});
|