A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/566fc567b8 below:

add diagnostics channel 'http2.client.stream.finish' · nodejs/node@566fc56 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+81

-0

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+81

-0

lines changed Original file line number Diff line number Diff line change

@@ -1224,6 +1224,14 @@ Emitted when a stream is started on the client.

1224 1224 1225 1225

Emitted when an error occurs during the processing of a stream on the client.

1226 1226 1227 +

`http2.client.stream.finish`

1228 + 1229 +

* `stream` {ClientHttp2Stream}

1230 +

* `headers` {HTTP/2 Headers Object}

1231 +

* `flags` {number}

1232 + 1233 +

Emitted when a stream is received on the client.

1234 + 1227 1235

#### Modules

1228 1236 1229 1237

> Stability: 1 - Experimental

Original file line number Diff line number Diff line change

@@ -188,6 +188,7 @@ const dc = require('diagnostics_channel');

188 188

const onClientStreamCreatedChannel = dc.channel('http2.client.stream.created');

189 189

const onClientStreamStartChannel = dc.channel('http2.client.stream.start');

190 190

const onClientStreamErrorChannel = dc.channel('http2.client.stream.error');

191 +

const onClientStreamFinishChannel = dc.channel('http2.client.stream.finish');

191 192 192 193

let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {

193 194

debug = fn;

@@ -427,6 +428,15 @@ function onSessionHeaders(handle, id, cat, flags, headers, sensitiveHeaders) {

427 428

reqAsync.runInAsyncScope(process.nextTick, null, emit, stream, event, obj, flags, headers);

428 429

else

429 430

process.nextTick(emit, stream, event, obj, flags, headers);

431 +

if ((event === 'response' ||

432 +

event === 'push') &&

433 +

onClientStreamFinishChannel.hasSubscribers) {

434 +

onClientStreamFinishChannel.publish({

435 +

stream,

436 +

headers: obj,

437 +

flags: flags,

438 +

});

439 +

}

430 440

}

431 441

if (endOfStream) {

432 442

stream.push(null);

Original file line number Diff line number Diff line change

@@ -0,0 +1,63 @@

1 +

'use strict';

2 + 3 +

const common = require('../common');

4 +

if (!common.hasCrypto)

5 +

common.skip('missing crypto');

6 + 7 +

// This test ensures that the built-in HTTP/2 diagnostics channels are reporting

8 +

// the diagnostics messages for the 'http2.client.stream.finish' channel when

9 +

// ClientHttp2Streams are received by both:

10 +

// - the 'response' event

11 +

// - the 'push' event

12 + 13 +

const Countdown = require('../common/countdown');

14 +

const assert = require('assert');

15 +

const dc = require('diagnostics_channel');

16 +

const http2 = require('http2');

17 +

const { Duplex } = require('stream');

18 + 19 +

const clientHttp2StreamFinishCount = 2;

20 + 21 +

dc.subscribe('http2.client.stream.finish', common.mustCall(({ stream, headers, flags }) => {

22 +

// Since ClientHttp2Stream is not exported from any module, this just checks

23 +

// if the stream is an instance of Duplex and the constructor name is

24 +

// 'ClientHttp2Stream'.

25 +

assert.ok(stream instanceof Duplex);

26 +

assert.strictEqual(stream.constructor.name, 'ClientHttp2Stream');

27 + 28 +

assert.ok(headers && !Array.isArray(headers) && typeof headers === 'object');

29 + 30 +

assert.strictEqual(typeof flags, 'number');

31 +

}, clientHttp2StreamFinishCount));

32 + 33 +

const server = http2.createServer();

34 +

server.on('stream', common.mustCall((stream) => {

35 +

stream.respond();

36 +

stream.end();

37 + 38 +

stream.pushStream({}, common.mustSucceed((pushStream) => {

39 +

pushStream.respond();

40 +

pushStream.end();

41 +

}));

42 +

}));

43 + 44 +

server.listen(0, common.mustCall(() => {

45 +

const port = server.address().port;

46 +

const client = http2.connect(`http://localhost:${port}`);

47 + 48 +

const countdown = new Countdown(clientHttp2StreamFinishCount, () => {

49 +

client.close();

50 +

server.close();

51 +

});

52 + 53 +

const stream = client.request({});

54 +

stream.on('response', common.mustCall(() => {

55 +

countdown.dec();

56 +

}));

57 + 58 +

client.on('stream', common.mustCall((pushStream) => {

59 +

pushStream.on('push', common.mustCall(() => {

60 +

countdown.dec();

61 +

}));

62 +

}));

63 +

}));

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4