http2: report sent headers object in client stream dcs · nodejs/node@b7ea39d
@@ -18,36 +18,61 @@ const { Duplex } = require('stream');
18181919const clientHttp2StreamCreationCount = 2;
202021+let countdown;
22+let port;
23+2124dc.subscribe('http2.client.stream.created', common.mustCall(({ stream, headers }) => {
2225// Since ClientHttp2Stream is not exported from any module, this just checks
2326// if the stream is an instance of Duplex and the constructor name is
2427// 'ClientHttp2Stream'.
2528assert.ok(stream instanceof Duplex);
2629assert.strictEqual(stream.constructor.name, 'ClientHttp2Stream');
2730assert.ok(headers && !Array.isArray(headers) && typeof headers === 'object');
31+if (countdown.remaining === clientHttp2StreamCreationCount) {
32+// The request stream headers.
33+assert.deepStrictEqual(headers, {
34+'__proto__': null,
35+':method': 'GET',
36+':authority': `localhost:${port}`,
37+':scheme': 'http',
38+':path': '/',
39+'requestHeader': 'requestValue',
40+});
41+} else {
42+// The push stream headers.
43+assert.deepStrictEqual(headers, {
44+'__proto__': null,
45+':method': 'GET',
46+':authority': `localhost:${port}`,
47+':scheme': 'http',
48+':path': '/',
49+[http2.sensitiveHeaders]: [],
50+'pushheader': 'pushValue',
51+});
52+}
2853}, clientHttp2StreamCreationCount));
29543055const server = http2.createServer();
3156server.on('stream', common.mustCall((stream) => {
3257stream.respond();
3358stream.end();
345935-stream.pushStream({}, common.mustSucceed((pushStream) => {
60+stream.pushStream({ 'pushHeader': 'pushValue' }, common.mustSucceed((pushStream) => {
3661pushStream.respond();
3762pushStream.end();
3863}, 1));
3964}, 1));
40654166server.listen(0, common.mustCall(() => {
42-const port = server.address().port;
67+port = server.address().port;
4368const client = http2.connect(`http://localhost:${port}`);
446945-const countdown = new Countdown(clientHttp2StreamCreationCount, () => {
70+countdown = new Countdown(clientHttp2StreamCreationCount, () => {
4671client.close();
4772server.close();
4873});
497450-const stream = client.request({});
75+const stream = client.request(['requestHeader', 'requestValue']);
5176stream.on('response', common.mustCall(() => {
5277countdown.dec();
5378}));