From 020cf0925823037b0e5ab3aa230d1943e7c3d588 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 21 Sep 2018 14:14:04 -0700 Subject: [PATCH] http2: add ping event Add a `Http2Session` event whenever a non-ack `PING` is received. Fixes: https://github.com/nodejs/node/issues/18514 PR-URL: https://github.com/nodejs/node/pull/23009 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Ujjwal Sharma Reviewed-By: Anatoli Papirovski Reviewed-By: Denys Otrishko --- doc/api/http2.md | 10 +++++++ lib/internal/http2/core.js | 10 +++++++ src/env.h | 1 + src/node_http2.cc | 22 ++++++++------ test/parallel/test-http2-onping.js | 48 ++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 test/parallel/test-http2-onping.js diff --git a/doc/api/http2.md b/doc/api/http2.md index ad3a1bfef8e0fa..4cb114a669f22e 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -217,6 +217,16 @@ session.on('localSettings', (settings) => { }); ``` +#### Event: 'ping' + + +* `payload` {Buffer} The `PING` frame 8-byte payload + +The `'ping'` event is emitted whenever a `PING` frame is received from the +connected peer. + #### Event: 'remoteSettings'