• headers {HTTP/2 Headers Object}

    Sends a trailing HEADERS frame to the connected HTTP/2 peer. This method will cause the Http2Stream to be immediately closed and must only be called after the 'wantTrailers' event has been emitted. When sending a request or sending a response, the options.waitForTrailers option must be set in order to keep the Http2Stream open after the final DATA frame so that trailers can be sent.

    1. const http2 = require('http2');
    2. const server = http2.createServer();
    3. server.on('stream', (stream) => {
    4. stream.respond(undefined, { waitForTrailers: true });
    5. stream.on('wantTrailers', () => {
    6. stream.sendTrailers({ xyz: 'abc' });
    7. });
    8. stream.end('Hello World');
    9. });

    The HTTP/1 specification forbids trailers from containing HTTP/2 pseudo-header fields (e.g. ':method', ':path', etc).