@@ -11,7 +11,8 @@ const check = Buffer.from([0x00, 0x01, 0x00, 0x00, 0x10, 0x00,
11
11
0x00 , 0x05 , 0x00 , 0x00 , 0x40 , 0x00 ,
12
12
0x00 , 0x04 , 0x00 , 0x00 , 0xff , 0xff ,
13
13
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 ] ) ;
15
16
const val = http2 . getPackedSettings ( http2 . getDefaultSettings ( ) ) ;
16
17
assert . deepStrictEqual ( val , check ) ;
17
18
@@ -67,12 +68,27 @@ http2.getPackedSettings({ enablePush: false });
67
68
} ) ;
68
69
} ) ;
69
70
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
+
70
83
{
71
84
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 ] ) ;
76
92
77
93
const packed = http2 . getPackedSettings ( {
78
94
headerTableSize : 100 ,
@@ -81,9 +97,10 @@ http2.getPackedSettings({ enablePush: false });
81
97
maxConcurrentStreams : 200 ,
82
98
maxHeaderListSize : 100 ,
83
99
enablePush : true ,
100
+ enableConnectProtocol : false ,
84
101
foo : 'ignored'
85
102
} ) ;
86
- assert . strictEqual ( packed . length , 36 ) ;
103
+ assert . strictEqual ( packed . length , 42 ) ;
87
104
assert . deepStrictEqual ( packed , check ) ;
88
105
}
89
106
@@ -95,10 +112,13 @@ http2.getPackedSettings({ enablePush: false });
95
112
96
113
{
97
114
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 ] ) ;
102
122
103
123
[ 1 , true , '' , [ ] , { } , NaN ] . forEach ( ( input ) => {
104
124
common . expectsError ( ( ) => {
@@ -129,30 +149,38 @@ http2.getPackedSettings({ enablePush: false });
129
149
assert . strictEqual ( settings . maxConcurrentStreams , 200 ) ;
130
150
assert . strictEqual ( settings . maxHeaderListSize , 100 ) ;
131
151
assert . strictEqual ( settings . enablePush , true ) ;
152
+ assert . strictEqual ( settings . enableConnectProtocol , false ) ;
132
153
}
133
154
134
155
{
135
156
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 ] ) ;
137
159
138
160
const settings = http2 . getUnpackedSettings ( packed , { validate : true } ) ;
139
161
assert . strictEqual ( settings . enablePush , false ) ;
162
+ assert . strictEqual ( settings . enableConnectProtocol , false ) ;
140
163
}
141
164
{
142
165
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 ] ) ;
144
168
145
169
const settings = http2 . getUnpackedSettings ( packed , { validate : true } ) ;
146
170
assert . strictEqual ( settings . enablePush , true ) ;
171
+ assert . strictEqual ( settings . enableConnectProtocol , true ) ;
147
172
}
148
173
149
174
// Verify that passing {validate: true} does not throw.
150
175
{
151
176
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 ] ) ;
156
184
157
185
http2 . getUnpackedSettings ( packed , { validate : true } ) ;
158
186
}
0 commit comments