Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
http2: make response.end() return this
  • Loading branch information
mcollina committed Feb 16, 2018
commit 54facaaa28164227e801e015685759b087153b4f
5 changes: 5 additions & 0 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2617,11 +2617,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