summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-invalid-path-chars.js
blob: c1d0baa62c3e9b13e57d5c70e33838cc453f5783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';

const common = require('../common');
const assert = require('assert');
const http = require('http');

const expectedError = common.expectsError({
  code: 'ERR_UNESCAPED_CHARACTERS',
  type: TypeError,
  message: 'Request path contains unescaped characters'
}, 1320);
const theExperimentallyDeterminedNumber = 39;

function fail(path) {
  assert.throws(() => {
    http.request({ path }, assert.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));
  }
}