http2.getPackedSettings([settings])


  • settings HTTP/2 设置对象
  • 返回:<Buffer>

返回一个包含给定 HTTP/2 设置序列化表示的 Buffer 实例,如 HTTP/2 规范中所述。此方法旨在与 HTTP2-Settings 头字段一起使用。

【Returns a Buffer instance containing serialized representation of the given HTTP/2 settings as specified in the HTTP/2 specification. This is intended for use with the HTTP2-Settings header field.】

import { getPackedSettings } from 'node:http2';

const packed = getPackedSettings({ enablePush: false });

console.log(packed.toString('base64'));
// Prints: AAIAAAAAconst http2 = require('node:http2');

const packed = http2.getPackedSettings({ enablePush: false });

console.log(packed.toString('base64'));
// Prints: AAIAAAAA