Skip to content

Commit 54facaa

Browse files
committed
http2: make response.end() return this
1 parent 6dfd96e commit 54facaa

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

doc/api/http2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,11 +2617,16 @@ See [`response.socket`][].
26172617
#### response.end([data][, encoding][, callback])
26182618
<!-- YAML
26192619
added: v8.4.0
2620+
changes:
2621+
- version: REPLACEME
2622+
pr-url: https://github.com/nodejs/node/pull/18780
2623+
description: This method now returns a reference to `ServerResponse`.
26202624
-->
26212625

26222626
* `data` {string|Buffer}
26232627
* `encoding` {string}
26242628
* `callback` {Function}
2629+
* Returns: {this}
26252630

26262631
This method signals to the server that all of the response headers and body
26272632
have been sent; that server should consider this message complete.

lib/internal/http2/compat.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ class Http2ServerResponse extends Stream {
596596
this[kFinish]();
597597
else
598598
stream.end();
599+
600+
return this;
599601
}
600602

601603
destroy(err) {

test/parallel/test-http2-compat-serverrequest-end.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ server.listen(0, common.mustCall(function() {
2626

2727
server.close();
2828
}));
29-
response.end();
29+
assert.strictEqual(response.end(), response);
3030
}));
3131
}));
3232

0 commit comments

Comments
 (0)