mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
test: invalid chars in http client path
This test adds coverage for all the characters which are considered invalid in a http path. PR-URL: https://github.com/nodejs/node/pull/11964 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
89d9c3f4a7
commit
30f1e8ea04
1 changed files with 20 additions and 0 deletions
20
test/parallel/test-http-invalid-path-chars.js
Normal file
20
test/parallel/test-http-invalid-path-chars.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const expectedError = /^TypeError: Request path contains unescaped characters$/;
|
||||||
|
const theExperimentallyDeterminedNumber = 39;
|
||||||
|
|
||||||
|
function fail(path) {
|
||||||
|
assert.throws(() => {
|
||||||
|
http.request({ path }, common.fail);
|
||||||
|
}, expectedError);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i <= theExperimentallyDeterminedNumber; i++) {
|
||||||
|
const prefix = 'a'.repeat(i);
|
||||||
|
for (let i = 0; i <= 32; i++) {
|
||||||
|
fail(prefix + String.fromCodePoint(i));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue