/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v26.1.0
test/client-proxy/test-http-proxy-request-invalid-proxy.mjs
36 строк
794 B
Joyee Cheung
http,https: handle IPv6 with proxies
23 сен 2025, 02:19
Не верифицирован
23 сен 2025, 02:19
81af7b9
Код
Авторство
О чём код?
// This tests that constructing agents with invalid proxy URLs throws ERR_PROXY_INVALID_CONFIG. import '../common/index.mjs'; import assert from 'node:assert'; import http from 'node:http'; const testCases = [ { name: 'invalid IPv4 address', proxyUrl: 'http://256.256.256.256:8080', }, { name: 'invalid IPv6 address', proxyUrl: 'http://::1:8080', }, { name: 'missing host', proxyUrl: 'http://:8080', }, { name: 'non-numeric port', proxyUrl: 'http://proxy.example.com:port', }, ]; for (const testCase of testCases) { assert.throws(() => { new http.Agent({ proxyEnv: { HTTP_PROXY: testCase.proxyUrl, }, }); }, { code: 'ERR_PROXY_INVALID_CONFIG', message: `Invalid proxy URL: ${testCase.proxyUrl}`, }); }