'origin' 事件


每当客户端接收到 ORIGIN 帧时,则会触发 'origin' 事件。 该事件使用 origin 字符串的数组触发。 http2session.originSet 将被更新以包含接收到的来源。

const http2 = require('http2');
const client = http2.connect('https://example.org');

client.on('origin', (origins) => {
  for (let n = 0; n < origins.length; n++)
    console.log(origins[n]);
});

只有在使用安全 TLS 连接时才会触发 'origin' 事件。

The 'origin' event is emitted whenever an ORIGIN frame is received by the client. The event is emitted with an array of origin strings. The http2session.originSet will be updated to include the received origins.

const http2 = require('http2');
const client = http2.connect('https://example.org');

client.on('origin', (origins) => {
  for (let n = 0; n < origins.length; n++)
    console.log(origins[n]);
});

The 'origin' event is only emitted when using a secure TLS connection.