diff --git a/doc/api/http2.md b/doc/api/http2.md index ae08fe49a7bb50..da6df4f7e6acac 100755 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -346,6 +346,9 @@ added: REPLACEME * `weight` {number} Specifies the relative dependency of a stream in relation to other streams with the same `parent`. The value is a number between `1` and `256` (inclusive). + * `getTrailers` {Function} Callback function invoked to collect trailer + headers. + * Returns: {ClientHttp2Stream} For HTTP/2 Client `Http2Session` instances only, the `http2session.request()` @@ -371,6 +374,16 @@ req.on('response', (headers) => { }); ``` +When set, the `options.getTrailers()` function is called immediately after +queuing the last chunk of payload data to be sent. The callback is passed a +single object (with a `null` prototype) that the listener may used to specify +the trailing header fields to send to the peer. + +*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2 +"pseudo-header" fields (e.g. `':method'`, `':path'`, etc). An `'error'` event +will be emitted if the `getTrailers` callback attempts to set such header +fields. + #### http2session.rstStream(stream, code) - -The `'fetchTrailers'` event is emitted by the `Http2Stream` immediately after -queuing the last chunk of payload data to be sent. The listener callback is -passed a single object (with a `null` prototype) that the listener may used -to specify the trailing header fields to send to the peer. - -```js -stream.on('fetchTrailers', (trailers) => { - trailers['ABC'] = 'some value to send'; -}); -``` - -*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2 -"pseudo-header" fields (e.g. `':status'`, `':path'`, etc). An `'error'` event -will be emitted if the `'fetchTrailers'` event handler attempts to set such -header fields. - #### Event: 'frameError'