Skip to content

Commit

Permalink
http2: make response.end() return this
Browse files Browse the repository at this point in the history
PR-URL: #18780
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
mcollina committed Feb 19, 2018
1 parent 8118da7 commit 3d93f39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ class Http2ServerResponse extends Stream {
this[kFinish]();
else
stream.end();

return this;
}

destroy(err) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-compat-serverrequest-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ server.listen(0, common.mustCall(function() {

server.close();
}));
response.end();
assert.strictEqual(response.end(), response);
}));
}));

Expand Down

0 comments on commit 3d93f39

Please sign in to comment.