2017-03-21 15:47:25 +01:00
|
|
|
'use strict';
|
2017-07-22 19:23:04 +08:00
|
|
|
|
|
|
|
const common = require('../common');
|
2017-03-21 15:47:25 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
|
|
|
|
2017-07-22 19:23:04 +08:00
|
|
|
const expectedError = common.expectsError({
|
|
|
|
code: 'ERR_UNESCAPED_CHARACTERS',
|
|
|
|
type: TypeError,
|
|
|
|
message: 'Request path contains unescaped characters'
|
|
|
|
}, 1320);
|
2017-03-21 15:47:25 +01:00
|
|
|
const theExperimentallyDeterminedNumber = 39;
|
|
|
|
|
|
|
|
function fail(path) {
|
|
|
|
assert.throws(() => {
|
2017-04-09 10:53:30 -07:00
|
|
|
http.request({ path }, assert.fail);
|
2017-03-21 15:47:25 +01:00
|
|
|
}, 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));
|
|
|
|
}
|
|
|
|
}
|