事件:'altsvc'


【Event: 'altsvc'

每当客户端接收到 ALTSVC 帧时,会触发 'altsvc' 事件。该事件会携带 ALTSVC 值、源(origin)和流 ID。如果 ALTSVC 帧中未提供 origin,则 origin 将为空字符串。

【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.】

import { connect } from 'node:http2';
const client = connect('https://example.org');

client.on('altsvc', (alt, origin, streamId) => {
  console.log(alt);
  console.log(origin);
  console.log(streamId);
});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);
});