'altsvc' 事件


每当客户端接收到 ALTSVC 帧时,则会触发 'altsvc' 事件。 事件使用 ALTSVC 值、来源和流 ID 触发。 如果在 ALTSVC 帧中没有提供 origin,则 origin 将是空字符串。

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

client.on('altsvc', (alt, origin, streamId) => {
  console.log(alt);
  console.log(origin);
  console.log(streamId);
});

The 'altsvc' event is emitted whenever an ALTSVC frame is received by the client. The event is emitted with the ALTSVC value, origin, and stream ID. If no origin is provided in the ALTSVC frame, origin will be an empty string.

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

client.on('altsvc', (alt, origin, streamId) => {
  console.log(alt);
  console.log(origin);
  console.log(streamId);
});