Skip to content

Commit

Permalink
http2: make response.end() return this
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Feb 16, 2018
1 parent 6dfd96e commit 54facaa
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
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
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
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 54facaa

Please sign in to comment.