事件:'trailers'


🌐 Event: 'trailers'

  • headers HTTP/2 头对象 一个描述头信息的对象
  • flags <number> 相关的数字标志

当接收到与尾随头字段相关的头块时,会触发 'trailers' 事件。监听器回调会接收到与这些头关联的 HTTP/2 头部对象 和标志。

🌐 The 'trailers' event is emitted when a block of headers associated with trailing header fields is received. The listener callback is passed the HTTP/2 Headers Object and flags associated with the headers.

如果在接收到尾部信息之前调用了 http2stream.end(),并且没有读取或监听传入的数据,则此事件可能不会被触发。

🌐 This event might not be emitted if http2stream.end() is called before trailers are received and the incoming data is not being read or listened for.

stream.on('trailers', (headers, flags) => {
  console.log(headers);
});