@@ -11,7 +11,8 @@ const check = Buffer.from([0x00, 0x01, 0x00, 0x00, 0x10, 0x00,
1111 0x00 , 0x05 , 0x00 , 0x00 , 0x40 , 0x00 ,
1212 0x00 , 0x04 , 0x00 , 0x00 , 0xff , 0xff ,
1313 0x00 , 0x06 , 0x00 , 0x00 , 0xff , 0xff ,
14- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ] ) ;
14+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
15+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
1516const val = http2 . getPackedSettings ( http2 . getDefaultSettings ( ) ) ;
1617assert . deepStrictEqual ( val , check ) ;
1718
@@ -67,12 +68,27 @@ http2.getPackedSettings({ enablePush: false });
6768 } ) ;
6869} ) ;
6970
71+ [
72+ 1 , null , '' , Infinity , new Date ( ) , { } , NaN , [ false ]
73+ ] . forEach ( ( i ) => {
74+ assert . throws ( ( ) => {
75+ http2 . getPackedSettings ( { enableConnectProtocol : i } ) ;
76+ } , {
77+ code : 'ERR_HTTP2_INVALID_SETTING_VALUE' ,
78+ name : 'TypeError' ,
79+ message : `Invalid value for setting "enableConnectProtocol": ${ i } `
80+ } ) ;
81+ } ) ;
82+
7083{
7184 const check = Buffer . from ( [
72- 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x03 , 0x00 , 0x00 ,
73- 0x00 , 0xc8 , 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 , 0x00 , 0x04 ,
74- 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
75- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ] ) ;
85+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 ,
86+ 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0xc8 ,
87+ 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 ,
88+ 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x64 ,
89+ 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
90+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
91+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
7692
7793 const packed = http2 . getPackedSettings ( {
7894 headerTableSize : 100 ,
@@ -81,9 +97,10 @@ http2.getPackedSettings({ enablePush: false });
8197 maxConcurrentStreams : 200 ,
8298 maxHeaderListSize : 100 ,
8399 enablePush : true ,
100+ enableConnectProtocol : false ,
84101 foo : 'ignored'
85102 } ) ;
86- assert . strictEqual ( packed . length , 36 ) ;
103+ assert . strictEqual ( packed . length , 42 ) ;
87104 assert . deepStrictEqual ( packed , check ) ;
88105}
89106
@@ -95,10 +112,13 @@ http2.getPackedSettings({ enablePush: false });
95112
96113{
97114 const packed = Buffer . from ( [
98- 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x03 , 0x00 , 0x00 ,
99- 0x00 , 0xc8 , 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 , 0x00 , 0x04 ,
100- 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
101- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ] ) ;
115+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 ,
116+ 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0xc8 ,
117+ 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 ,
118+ 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x64 ,
119+ 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
120+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
121+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
102122
103123 [ 1 , true , '' , [ ] , { } , NaN ] . forEach ( ( input ) => {
104124 common . expectsError ( ( ) => {
@@ -129,30 +149,38 @@ http2.getPackedSettings({ enablePush: false });
129149 assert . strictEqual ( settings . maxConcurrentStreams , 200 ) ;
130150 assert . strictEqual ( settings . maxHeaderListSize , 100 ) ;
131151 assert . strictEqual ( settings . enablePush , true ) ;
152+ assert . strictEqual ( settings . enableConnectProtocol , false ) ;
132153}
133154
134155{
135156 const packed = Buffer . from ( [
136- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
157+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 ,
158+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
137159
138160 const settings = http2 . getUnpackedSettings ( packed , { validate : true } ) ;
139161 assert . strictEqual ( settings . enablePush , false ) ;
162+ assert . strictEqual ( settings . enableConnectProtocol , false ) ;
140163}
141164{
142165 const packed = Buffer . from ( [
143- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x64 ] ) ;
166+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x64 ,
167+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x64 ] ) ;
144168
145169 const settings = http2 . getUnpackedSettings ( packed , { validate : true } ) ;
146170 assert . strictEqual ( settings . enablePush , true ) ;
171+ assert . strictEqual ( settings . enableConnectProtocol , true ) ;
147172}
148173
149174// Verify that passing {validate: true} does not throw.
150175{
151176 const packed = Buffer . from ( [
152- 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x03 , 0x00 , 0x00 ,
153- 0x00 , 0xc8 , 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 , 0x00 , 0x04 ,
154- 0x00 , 0x00 , 0x00 , 0x64 , 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
155- 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ] ) ;
177+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x64 ,
178+ 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0xc8 ,
179+ 0x00 , 0x05 , 0x00 , 0x00 , 0x4e , 0x20 ,
180+ 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x64 ,
181+ 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x64 ,
182+ 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
183+ 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ;
156184
157185 http2 . getUnpackedSettings ( packed , { validate : true } ) ;
158186}
0 commit comments