事件:'headers'


【Event: 'headers'

  • headers HTTP/2 头对象
  • flags <number>
  • rawHeaders HTTP/2 原始头信息

'headers' 事件在接收到流的额外头块时触发,例如接收到一块 1xx 信息性头。监听器回调会传入与头关联的 HTTP/2 头部对象、标志,以及原始格式的头信息(见 HTTP/2 原始头)。

【The 'headers' event is emitted when an additional block of headers is received for a stream, such as when a block of 1xx informational headers is received. The listener callback is passed the HTTP/2 Headers Object, flags associated with the headers, and the headers in raw format (see HTTP/2 Raw Headers).】

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