diff options
author | James M Snell <jasnell@gmail.com> | 2018-09-21 14:14:04 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-09-23 16:36:24 -0700 |
commit | a0c1326257b9679b056d8611ccdee2d6757b0bf0 (patch) | |
tree | 4914f6072d5b6b4365cda762114c25923f22145c /lib | |
parent | c67d3d0c3caf74795871f813dbef2ec3fc196e58 (diff) | |
download | android-node-v8-a0c1326257b9679b056d8611ccdee2d6757b0bf0.tar.gz android-node-v8-a0c1326257b9679b056d8611ccdee2d6757b0bf0.tar.bz2 android-node-v8-a0c1326257b9679b056d8611ccdee2d6757b0bf0.zip |
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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/http2/core.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 9cfa2fe4cc..d5ea26374f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -346,6 +346,15 @@ function submitRstStream(code) { } } +function onPing(payload) { + const session = this[kOwner]; + if (session.destroyed) + return; + session[kUpdateTimer](); + debug(`Http2Session ${sessionName(session[kType])}: new ping received`); + session.emit('ping', payload); +} + // Called when the stream is closed either by sending or receiving an // RST_STREAM frame, or through a natural end-of-stream. // If the writable and readable sides of the stream are still open at this @@ -821,6 +830,7 @@ function setupHandle(socket, type, options) { handle.error = onSessionInternalError; handle.onpriority = onPriority; handle.onsettings = onSettings; + handle.onping = onPing; handle.onheaders = onSessionHeaders; handle.onframeerror = onFrameError; handle.ongoawaydata = onGoawayData; |