MCPcopy Index your code
hub / github.com/nodejs/node / getUnpackedSettings

Function getUnpackedSettings

lib/internal/http2/core.js:3708–3754  ·  view source on GitHub ↗
(buf, options = kEmptyObject)

Source from the content-addressed store, hash-verified

3706}
3707
3708function getUnpackedSettings(buf, options = kEmptyObject) {
3709 if (!isArrayBufferView(buf) || buf.length === undefined) {
3710 throw new ERR_INVALID_ARG_TYPE('buf',
3711 ['Buffer', 'TypedArray'], buf);
3712 }
3713 if (buf.length % 6 !== 0)
3714 throw new ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH();
3715 const settings = {};
3716 let offset = 0;
3717 while (offset < buf.length) {
3718 const id = readUInt16BE(buf, offset);
3719 offset += 2;
3720 const value = readUInt32BE(buf, offset);
3721 switch (id) {
3722 case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
3723 settings.headerTableSize = value;
3724 break;
3725 case NGHTTP2_SETTINGS_ENABLE_PUSH:
3726 settings.enablePush = value !== 0;
3727 break;
3728 case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
3729 settings.maxConcurrentStreams = value;
3730 break;
3731 case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
3732 settings.initialWindowSize = value;
3733 break;
3734 case NGHTTP2_SETTINGS_MAX_FRAME_SIZE:
3735 settings.maxFrameSize = value;
3736 break;
3737 case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
3738 settings.maxHeaderListSize = settings.maxHeaderSize = value;
3739 break;
3740 case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
3741 settings.enableConnectProtocol = value !== 0;
3742 break;
3743 default:
3744 settings.customSettings ||= {};
3745 settings.customSettings[id] = value;
3746 }
3747 offset += 4;
3748 }
3749
3750 if (options != null && options.validate)
3751 validateSettings(settings);
3752
3753 return settings;
3754}
3755
3756function performServerHandshake(socket, options = kEmptyObject) {
3757 options = initializeOptions(options);

Callers

nothing calls this directly

Calls 2

readUInt16BEFunction · 0.85
readUInt32BEFunction · 0.85

Tested by

no test coverage detected