(winterCGHeaders: WebFetchHeaders)
| 47 | * The header keys will be lower case: e.g. A "Content-Type" header will be stored as "content-type". |
| 48 | */ |
| 49 | export function winterCGHeadersToDict(winterCGHeaders: WebFetchHeaders): Record<string, string> { |
| 50 | const headers: Record<string, string> = {}; |
| 51 | try { |
| 52 | winterCGHeaders.forEach((value, key) => { |
| 53 | if (typeof value === 'string') { |
| 54 | // We check that value is a string even though it might be redundant to make sure prototype pollution is not possible. |
| 55 | headers[key] = value; |
| 56 | } |
| 57 | }); |
| 58 | } catch { |
| 59 | // just return the empty headers |
| 60 | } |
| 61 | |
| 62 | return headers; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Convert common request headers to a simple dictionary. |
no test coverage detected