1
- import type { MapLikeObj , SignInfo , SignatureHashAlgorithmUpperSnake , HeadersLike , HeadersValueLike } from './types.js' ;
1
+ import type { MapLikeObj , SignInfo , SignatureHashAlgorithmUpperSnake , HeadersLike , HeadersValueLike , HeadersValueLikeArrayable } from './types.js' ;
2
2
import { ParsedAlgorithmIdentifier , getNistCurveFromOid , getPublicKeyAlgorithmNameFromOid } from './pem/spki.js' ;
3
3
import type { webcrypto } from 'node:crypto' ;
4
4
@@ -17,7 +17,7 @@ export function removeObsoleteLineFolding(str: string): string {
17
17
/**
18
18
* RFC 9421 2.1 (If the correctly combined value is not directly available for a given field by an implementation, ...)
19
19
*/
20
- export function canonicalizeHeaderValue ( value : HeadersValueLike ) : string {
20
+ export function canonicalizeHeaderValue ( value : HeadersValueLikeArrayable ) : string {
21
21
if ( typeof value === 'number' ) return value . toString ( ) ;
22
22
if ( ! value ) return '' ;
23
23
if ( typeof value === 'string' ) return removeObsoleteLineFolding ( value ) . trim ( ) ;
@@ -102,13 +102,13 @@ export function toStringOrToLc(src: string | number | undefined | null): string
102
102
* Convert rawHeaders to object
103
103
* rawHeaders: https://nodejs.org/api/http2.html#requestrawheaders
104
104
*/
105
- export function correctHeaders ( src : ( string | number | undefined | null ) [ ] ) : Record < string , ( string | number ) [ ] > {
105
+ export function correctHeaders ( src : HeadersValueLike [ ] ) : Record < string , ( string | number ) [ ] > {
106
106
return src . reduce ( ( dst , prop , i ) => {
107
107
if ( i % 2 === 0 ) {
108
108
if ( typeof prop !== 'string' ) {
109
109
throw new Error ( `Invalid header key type '${ typeof prop } ' of ${ prop } ` ) ;
110
110
}
111
- if ( prop in dst ) return dst ;
111
+ if ( prop . toLowerCase ( ) in dst ) return dst ;
112
112
dst [ prop . toLowerCase ( ) ] = [ ] ;
113
113
} else {
114
114
dst [ toStringOrToLc ( src [ i - 1 ] ) ] . push ( prop == null ? '' : prop . toString ( ) ) ;
0 commit comments