@@ -175,11 +175,11 @@ const {
175175 ':statuS' : 204 ,
176176 } ;
177177
178- common . expectsError ( {
178+ common . expectsError ( ( ) => mapToHeaders ( headers ) , {
179179 code : 'ERR_HTTP2_HEADER_SINGLE_VALUE' ,
180180 type : TypeError ,
181181 message : 'Header field ":status" must only have a single value'
182- } ) ( mapToHeaders ( headers ) ) ;
182+ } ) ;
183183}
184184
185185// The following are not allowed to have multiple values
@@ -224,10 +224,10 @@ const {
224224 HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS
225225] . forEach ( ( name ) => {
226226 const msg = `Header field "${ name } " must only have a single value` ;
227- common . expectsError ( {
227+ common . expectsError ( ( ) => mapToHeaders ( { [ name ] : [ 1 , 2 , 3 ] } ) , {
228228 code : 'ERR_HTTP2_HEADER_SINGLE_VALUE' ,
229229 message : msg
230- } ) ( mapToHeaders ( { [ name ] : [ 1 , 2 , 3 ] } ) ) ;
230+ } ) ;
231231} ) ;
232232
233233[
@@ -281,30 +281,32 @@ const {
281281 'Proxy-Connection' ,
282282 'Keep-Alive'
283283] . forEach ( ( name ) => {
284- common . expectsError ( {
284+ common . expectsError ( ( ) => mapToHeaders ( { [ name ] : 'abc' } ) , {
285285 code : 'ERR_HTTP2_INVALID_CONNECTION_HEADERS' ,
286286 name : 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]' ,
287287 message : 'HTTP/1 Connection specific headers are forbidden: ' +
288288 `"${ name . toLowerCase ( ) } "`
289- } ) ( mapToHeaders ( { [ name ] : 'abc' } ) ) ;
289+ } ) ;
290290} ) ;
291291
292- common . expectsError ( {
292+ common . expectsError ( ( ) => mapToHeaders ( { [ HTTP2_HEADER_TE ] : [ 'abc' ] } ) , {
293293 code : 'ERR_HTTP2_INVALID_CONNECTION_HEADERS' ,
294294 name : 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]' ,
295295 message : 'HTTP/1 Connection specific headers are forbidden: ' +
296296 `"${ HTTP2_HEADER_TE } "`
297- } ) ( mapToHeaders ( { [ HTTP2_HEADER_TE ] : [ 'abc' ] } ) ) ;
297+ } ) ;
298298
299- common . expectsError ( {
300- code : 'ERR_HTTP2_INVALID_CONNECTION_HEADERS' ,
301- name : 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]' ,
302- message : 'HTTP/1 Connection specific headers are forbidden: ' +
303- `"${ HTTP2_HEADER_TE } "`
304- } ) ( mapToHeaders ( { [ HTTP2_HEADER_TE ] : [ 'abc' , 'trailers' ] } ) ) ;
299+ common . expectsError (
300+ ( ) => mapToHeaders ( { [ HTTP2_HEADER_TE ] : [ 'abc' , 'trailers' ] } ) , {
301+ code : 'ERR_HTTP2_INVALID_CONNECTION_HEADERS' ,
302+ name : 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]' ,
303+ message : 'HTTP/1 Connection specific headers are forbidden: ' +
304+ `"${ HTTP2_HEADER_TE } "`
305+ } ) ;
305306
306- assert ( ! ( mapToHeaders ( { te : 'trailers' } ) instanceof Error ) ) ;
307- assert ( ! ( mapToHeaders ( { te : [ 'trailers' ] } ) instanceof Error ) ) ;
307+ // These should not throw
308+ mapToHeaders ( { te : 'trailers' } ) ;
309+ mapToHeaders ( { te : [ 'trailers' ] } ) ;
308310
309311
310312{
0 commit comments