doc: update pushStream docs to use err first
Refs: https://github.com/nodejs/node/pull/17406#issuecomment-356661798 PR-URL: https://github.com/nodejs/node/pull/18088 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
parent
7c84f19455
commit
078b7a2a65
@ -1174,14 +1174,16 @@ added: v8.4.0
|
|||||||
* Returns: {undefined}
|
* Returns: {undefined}
|
||||||
|
|
||||||
Initiates a push stream. The callback is invoked with the new `Http2Stream`
|
Initiates a push stream. The callback is invoked with the new `Http2Stream`
|
||||||
instance created for the push stream.
|
instance created for the push stream passed as the second argument, or an
|
||||||
|
`Error` passed as the first argument.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
server.on('stream', (stream) => {
|
server.on('stream', (stream) => {
|
||||||
stream.respond({ ':status': 200 });
|
stream.respond({ ':status': 200 });
|
||||||
stream.pushStream({ ':path': '/' }, (pushStream) => {
|
stream.pushStream({ ':path': '/' }, (err, pushStream) => {
|
||||||
|
if (err) throw err;
|
||||||
pushStream.respond({ ':status': 200 });
|
pushStream.respond({ ':status': 200 });
|
||||||
pushStream.end('some pushed data');
|
pushStream.end('some pushed data');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user