node/test/parallel/test-http2-priority-event.js
Matteo Collina a63126409a
http2: remove support for priority signaling
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Refs: https://datatracker.ietf.org/doc/html/rfc9113#section-5.3.1
PR-URL: https://github.com/nodejs/node/pull/58293
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2025-06-03 09:09:40 +00:00

61 lines
1.3 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const h2 = require('http2');
common.expectWarning(
'DeprecationWarning',
'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993',
'DEP0194');
const server = h2.createServer();
// We use the lower-level API here
server.on('stream', common.mustCall(onStream));
function onStream(stream, headers, flags) {
stream.priority({
parent: 0,
weight: 1,
exclusive: false
});
stream.respond({
'content-type': 'text/html',
':status': 200
});
stream.end('hello world');
}
server.listen(0);
server.on('priority', common.mustNotCall());
server.on('listening', common.mustCall(() => {
const client = h2.connect(`http://localhost:${server.address().port}`);
const req = client.request({ ':path': '/' });
client.on('connect', () => {
req.priority({
parent: 0,
weight: 1,
exclusive: false
});
});
// The priority event is not supported anymore by nghttp2
// since 1.65.0.
req.on('priority', common.mustNotCall());
req.on('response', common.mustCall());
req.resume();
req.on('end', common.mustCall(() => {
server.close();
client.close();
}));
req.end();
}));