阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js http2stream.sendTrailers

      Node.js http2stream.sendTrailers(headers)

      新增于: v10.0.0

      • 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.

      const http2 = require('http2');
      const server = http2.createServer();
      server.on('stream', (stream) => {
        stream.respond(undefined, { waitForTrailers: true });
        stream.on('wantTrailers', () => {
          stream.sendTrailers({ xyz: 'abc' });
        });
        stream.end('Hello World');
      });
      

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


      更多内容请参考:Node.js HTTP2,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录