@@ -9,6 +9,7 @@ if (!common.hasCrypto)
9
9
common . skip ( 'missing crypto' ) ;
10
10
const assert = require ( 'assert' ) ;
11
11
const { mapToHeaders, toHeaderObject } = require ( 'internal/http2/util' ) ;
12
+ const { sensitiveHeaders } = require ( 'http2' ) ;
12
13
const { internalBinding } = require ( 'internal/test/binding' ) ;
13
14
const {
14
15
HTTP2_HEADER_STATUS ,
@@ -102,8 +103,9 @@ const {
102
103
103
104
assert . deepStrictEqual (
104
105
mapToHeaders ( headers ) ,
105
- [ [ ':path' , 'abc' , ':status' , '200' , 'abc' , '1' , 'xyz' , '1' , 'xyz' , '2' ,
106
- 'xyz' , '3' , 'xyz' , '4' , 'bar' , '1' , '' ] . join ( '\0' ) , 8 ]
106
+ [ [ ':path' , 'abc\0' , ':status' , '200\0' , 'abc' , '1\0' , 'xyz' , '1\0' ,
107
+ 'xyz' , '2\0' , 'xyz' , '3\0' , 'xyz' , '4\0' , 'bar' , '1\0' , '' ] . join ( '\0' ) ,
108
+ 8 ]
107
109
) ;
108
110
}
109
111
@@ -118,8 +120,8 @@ const {
118
120
119
121
assert . deepStrictEqual (
120
122
mapToHeaders ( headers ) ,
121
- [ [ ':status' , '200' , ':path' , 'abc' , 'abc' , '1' , 'xyz' , '1' , 'xyz' , '2 ',
122
- 'xyz' , '3 ' , 'xyz' , '4' , '' ] . join ( '\0' ) , 7 ]
123
+ [ [ ':status' , '200\0 ' , ':path' , 'abc\0 ' , 'abc' , '1\0 ' , 'xyz' , '1\0 ' ,
124
+ 'xyz' , '2\0' , 'xyz' , '3\0 ', 'xyz' , '4\0 ' , '' ] . join ( '\0' ) , 7 ]
123
125
) ;
124
126
}
125
127
@@ -135,8 +137,8 @@ const {
135
137
136
138
assert . deepStrictEqual (
137
139
mapToHeaders ( headers ) ,
138
- [ [ ':status' , '200' , ':path' , 'abc' , 'abc' , '1' , 'xyz' , '1' , 'xyz' , '2 ',
139
- 'xyz' , '3 ' , 'xyz' , '4' , '' ] . join ( '\0' ) , 7 ]
140
+ [ [ ':status' , '200\0 ' , ':path' , 'abc\0 ' , 'abc' , '1\0 ' , 'xyz' , '1\0 ' ,
141
+ 'xyz' , '2\0' , 'xyz' , '3\0 ', 'xyz' , '4\0 ' , '' ] . join ( '\0' ) , 7 ]
140
142
) ;
141
143
}
142
144
@@ -151,8 +153,8 @@ const {
151
153
152
154
assert . deepStrictEqual (
153
155
mapToHeaders ( headers ) ,
154
- [ [ ':status' , '200' , ':path' , 'abc' , 'xyz' , '1' , 'xyz' , '2' , 'xyz' , '3 ',
155
- 'xyz' , '4 ' , '' ] . join ( '\0' ) , 6 ]
156
+ [ [ ':status' , '200\0 ' , ':path' , 'abc\0 ' , 'xyz' , '1\0 ' , 'xyz' , '2\0 ' ,
157
+ 'xyz' , '3\0' , 'xyz' , '4\0 ', '' ] . join ( '\0' ) , 6 ]
156
158
) ;
157
159
}
158
160
@@ -164,7 +166,7 @@ const {
164
166
} ;
165
167
assert . deepStrictEqual (
166
168
mapToHeaders ( headers ) ,
167
- [ [ 'set-cookie' , 'foo=bar' , '' ] . join ( '\0' ) , 1 ]
169
+ [ [ 'set-cookie' , 'foo=bar\0 ' , '' ] . join ( '\0' ) , 1 ]
168
170
) ;
169
171
}
170
172
@@ -182,6 +184,23 @@ const {
182
184
} ) ;
183
185
}
184
186
187
+ {
188
+ const headers = {
189
+ 'abc' : 1 ,
190
+ ':path' : 'abc' ,
191
+ ':status' : [ 200 ] ,
192
+ ':authority' : [ ] ,
193
+ 'xyz' : [ 1 , 2 , 3 , 4 ] ,
194
+ [ sensitiveHeaders ] : [ 'xyz' ]
195
+ } ;
196
+
197
+ assert . deepStrictEqual (
198
+ mapToHeaders ( headers ) ,
199
+ [ ':status\x00200\x00\x00:path\x00abc\x00\x00abc\x001\x00\x00' +
200
+ 'xyz\x001\x00\x01xyz\x002\x00\x01xyz\x003\x00\x01xyz\x004\x00\x01' , 7 ]
201
+ ) ;
202
+ }
203
+
185
204
// The following are not allowed to have multiple values
186
205
[
187
206
HTTP2_HEADER_STATUS ,
0 commit comments