@@ -133,8 +133,8 @@ http2.getPackedSettings({ enablePush: false });
133
133
code : 'ERR_INVALID_ARG_TYPE' ,
134
134
name : 'TypeError' ,
135
135
message :
136
- 'The "buf" argument must be an instance of Buffer, TypedArray, or ' +
137
- `DataView. ${ common . invalidArgTypeHelper ( input ) } `
136
+ 'The "buf" argument must be an instance of Buffer or TypedArray. ' +
137
+ common . invalidArgTypeHelper ( input )
138
138
} ) ;
139
139
} ) ;
140
140
@@ -159,6 +159,58 @@ http2.getPackedSettings({ enablePush: false });
159
159
assert . strictEqual ( settings . enableConnectProtocol , false ) ;
160
160
}
161
161
162
+ {
163
+ const packed = new Uint16Array ( [
164
+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 ,
165
+ 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0xc8 ,
166
+ 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 ,
167
+ 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x64 ,
168
+ 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
169
+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
170
+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
171
+
172
+ assert . throws ( ( ) => {
173
+ http2 . getUnpackedSettings ( packed . slice ( 5 ) ) ;
174
+ } , {
175
+ code : 'ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH' ,
176
+ name : 'RangeError' ,
177
+ message : 'Packed settings length must be a multiple of six'
178
+ } ) ;
179
+
180
+ const settings = http2 . getUnpackedSettings ( packed ) ;
181
+
182
+ assert ( settings ) ;
183
+ assert . strictEqual ( settings . headerTableSize , 100 ) ;
184
+ assert . strictEqual ( settings . initialWindowSize , 100 ) ;
185
+ assert . strictEqual ( settings . maxFrameSize , 20000 ) ;
186
+ assert . strictEqual ( settings . maxConcurrentStreams , 200 ) ;
187
+ assert . strictEqual ( settings . maxHeaderListSize , 100 ) ;
188
+ assert . strictEqual ( settings . maxHeaderSize , 100 ) ;
189
+ assert . strictEqual ( settings . enablePush , true ) ;
190
+ assert . strictEqual ( settings . enableConnectProtocol , false ) ;
191
+ }
192
+
193
+ {
194
+ const packed = new DataView ( Buffer . from ( [
195
+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 ,
196
+ 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0xc8 ,
197
+ 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 ,
198
+ 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x64 ,
199
+ 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
200
+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
201
+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) . buffer ) ;
202
+
203
+ assert . throws ( ( ) => {
204
+ http2 . getUnpackedSettings ( packed ) ;
205
+ } , {
206
+ code : 'ERR_INVALID_ARG_TYPE' ,
207
+ name : 'TypeError' ,
208
+ message :
209
+ 'The "buf" argument must be an instance of Buffer or TypedArray.' +
210
+ common . invalidArgTypeHelper ( packed )
211
+ } ) ;
212
+ }
213
+
162
214
{
163
215
const packed = Buffer . from ( [
164
216
0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 ,
0 commit comments