2020-05-01 16:49:02 +05:30
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto) { common.skip('missing crypto'); }
|
|
|
|
const assert = require('assert');
|
|
|
|
const http2 = require('http2');
|
|
|
|
|
|
|
|
const server1 = http2.createServer();
|
|
|
|
|
|
|
|
server1.listen(0, common.mustCall(() => {
|
|
|
|
const session = http2.connect(`http://localhost:${server1.address().port}`);
|
|
|
|
// Check for req headers
|
2020-04-25 03:37:43 +05:30
|
|
|
assert.throws(() => {
|
|
|
|
session.request({ 'no underscore': 123 });
|
|
|
|
}, {
|
|
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
|
|
|
});
|
2025-04-17 19:16:52 +02:00
|
|
|
session.close();
|
|
|
|
server1.close();
|
2020-05-01 16:49:02 +05:30
|
|
|
}));
|
|
|
|
|
|
|
|
const server2 = http2.createServer(common.mustCall((req, res) => {
|
|
|
|
// check for setHeader
|
2020-04-25 03:37:43 +05:30
|
|
|
assert.throws(() => {
|
|
|
|
res.setHeader('x y z', 123);
|
|
|
|
}, {
|
|
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
|
|
|
});
|
2020-05-01 16:49:02 +05:30
|
|
|
res.end();
|
|
|
|
}));
|
|
|
|
|
|
|
|
server2.listen(0, common.mustCall(() => {
|
|
|
|
const session = http2.connect(`http://localhost:${server2.address().port}`);
|
|
|
|
const req = session.request();
|
2020-04-25 03:37:43 +05:30
|
|
|
req.on('end', common.mustCall(() => {
|
2020-05-01 16:49:02 +05:30
|
|
|
session.close();
|
|
|
|
server2.close();
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
const server3 = http2.createServer(common.mustCall((req, res) => {
|
|
|
|
// check for writeHead
|
|
|
|
assert.throws(common.mustCall(() => {
|
|
|
|
res.writeHead(200, {
|
|
|
|
'an invalid header': 123
|
|
|
|
});
|
|
|
|
}), {
|
2020-04-25 03:37:43 +05:30
|
|
|
code: 'ERR_INVALID_HTTP_TOKEN'
|
2020-05-01 16:49:02 +05:30
|
|
|
});
|
|
|
|
res.end();
|
|
|
|
}));
|
|
|
|
|
|
|
|
server3.listen(0, common.mustCall(() => {
|
|
|
|
const session = http2.connect(`http://localhost:${server3.address().port}`);
|
|
|
|
const req = session.request();
|
2020-04-25 03:37:43 +05:30
|
|
|
req.on('end', common.mustCall(() => {
|
2020-05-01 16:49:02 +05:30
|
|
|
server3.close();
|
|
|
|
session.close();
|
|
|
|
}));
|
|
|
|
}));
|