aboutsummaryrefslogtreecommitdiff
path: root/lib/internal/http2
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-10 13:33:46 -0700
committerJames M Snell <jasnell@gmail.com>2018-08-15 15:58:41 -0700
commit32902d09b43e9d7f19eb6178ef5db835652d97c1 (patch)
tree1e2ebe3a42f0c592555589f8fc830619f66fce3f /lib/internal/http2
parent755520c4c3f9e1f85268d65ca647dec076e9a17a (diff)
downloadandroid-node-v8-32902d09b43e9d7f19eb6178ef5db835652d97c1.tar.gz
android-node-v8-32902d09b43e9d7f19eb6178ef5db835652d97c1.tar.bz2
android-node-v8-32902d09b43e9d7f19eb6178ef5db835652d97c1.zip
http2: emit timeout on compat request and response
Fixes: https://github.com/nodejs/node/issues/20079 PR-URL: https://github.com/nodejs/node/pull/22252 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/internal/http2')
-rw-r--r--lib/internal/http2/compat.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js
index 33f636f69b..40276d8723 100644
--- a/lib/internal/http2/compat.js
+++ b/lib/internal/http2/compat.js
@@ -241,6 +241,13 @@ function onStreamCloseRequest() {
req.emit('close');
}
+function onStreamTimeout(kind) {
+ return function onStreamTimeout() {
+ const obj = this[kind];
+ obj.emit('timeout');
+ };
+}
+
class Http2ServerRequest extends Readable {
constructor(stream, headers, options, rawHeaders) {
super(options);
@@ -263,6 +270,7 @@ class Http2ServerRequest extends Readable {
stream.on('error', onStreamError);
stream.on('aborted', onStreamAbortedRequest);
stream.on('close', onStreamCloseRequest);
+ stream.on('timeout', onStreamTimeout(kRequest));
this.on('pause', onRequestPause);
this.on('resume', onRequestResume);
}
@@ -416,6 +424,7 @@ class Http2ServerResponse extends Stream {
stream.on('aborted', onStreamAbortedResponse);
stream.on('close', onStreamCloseResponse);
stream.on('wantTrailers', onStreamTrailersReady);
+ stream.on('timeout', onStreamTimeout(kResponse));
}
// User land modules such as finalhandler just check truthiness of this