diff --git a/doc/api/http2.md b/doc/api/http2.md index 66cf7aafa0ff48..c73ed3b0bd2fb1 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2624,11 +2624,16 @@ See [`response.socket`][]. #### response.end([data][, encoding][, callback]) * `data` {string|Buffer} * `encoding` {string} * `callback` {Function} +* Returns: {this} This method signals to the server that all of the response headers and body have been sent; that server should consider this message complete. diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 5e6c51377e94ba..9670843176b77e 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -596,6 +596,8 @@ class Http2ServerResponse extends Stream { this[kFinish](); else stream.end(); + + return this; } destroy(err) { diff --git a/test/parallel/test-http2-compat-serverrequest-end.js b/test/parallel/test-http2-compat-serverrequest-end.js index d34372118582db..45a678d1a950d1 100644 --- a/test/parallel/test-http2-compat-serverrequest-end.js +++ b/test/parallel/test-http2-compat-serverrequest-end.js @@ -26,7 +26,7 @@ server.listen(0, common.mustCall(function() { server.close(); })); - response.end(); + assert.strictEqual(response.end(), response); })); }));