summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/http2.md5
-rw-r--r--lib/internal/http2/compat.js2
-rw-r--r--test/parallel/test-http2-compat-serverrequest-end.js2
3 files changed, 8 insertions, 1 deletions
diff --git a/doc/api/http2.md b/doc/api/http2.md
index 66cf7aafa0..c73ed3b0bd 100644
--- a/doc/api/http2.md
+++ b/doc/api/http2.md
@@ -2624,11 +2624,16 @@ See [`response.socket`][].
#### response.end([data][, encoding][, callback])
<!-- YAML
added: v8.4.0
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/18780
+ description: This method now returns a reference to `ServerResponse`.
-->
* `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 5e6c51377e..9670843176 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 d343721185..45a678d1a9 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);
}));
}));