mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

Some checks failed
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
V8 patch update / v8-update (push) Has been cancelled
OpenSSL update / openssl-update (push) Has been cancelled
Timezone update / timezone_update (push) Has been cancelled
This also notably changes error handling for request(). Previously some invalid header values (but not all) would cause the session to be unnecessarily destroyed automatically, e.g. passing an unparseable header name to request(). This is no longer the case: header validation failures will throw an error, but will not destroy the session or emit 'error' events. PR-URL: https://github.com/nodejs/node/pull/57917 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
82 lines
1.9 KiB
JavaScript
82 lines
1.9 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) { common.skip('missing crypto'); }
|
|
|
|
// Check for:
|
|
// Spaced headers
|
|
// Pseudo headers
|
|
// Capitalized headers
|
|
|
|
const http2 = require('http2');
|
|
const { throws } = require('assert');
|
|
|
|
{
|
|
const server = http2.createServer(common.mustCall((req, res) => {
|
|
throws(() => {
|
|
res.setHeader(':path', '/');
|
|
}, {
|
|
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED'
|
|
});
|
|
throws(() => {
|
|
res.setHeader('t est', 123);
|
|
}, {
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
|
});
|
|
res.setHeader('TEST', 123);
|
|
res.setHeader('test_', 123);
|
|
res.setHeader(' test', 123);
|
|
res.end();
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const session = http2.connect(`http://localhost:${server.address().port}`);
|
|
session.request({ 'test_': 123, 'TEST': 123 })
|
|
.on('end', common.mustCall(() => {
|
|
session.close();
|
|
server.close();
|
|
}));
|
|
}));
|
|
}
|
|
|
|
{
|
|
const server = http2.createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const session = http2.connect(`http://localhost:${server.address().port}`);
|
|
throws(() => {
|
|
session.request({ 't est': 123 });
|
|
}, {
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
|
});
|
|
session.close();
|
|
server.close();
|
|
}));
|
|
}
|
|
|
|
{
|
|
const server = http2.createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const session = http2.connect(`http://localhost:${server.address().port}`);
|
|
throws(() => {
|
|
session.request({ ' test': 123 });
|
|
}, {
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
|
});
|
|
session.close();
|
|
server.close();
|
|
}));
|
|
}
|
|
|
|
{
|
|
const server = http2.createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const session = http2.connect(`http://localhost:${server.address().port}`);
|
|
throws(() => {
|
|
session.request({ ':test': 123 });
|
|
}, {
|
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER'
|
|
});
|
|
session.close();
|
|
server.close();
|
|
}));
|
|
}
|