| 22 | new Set(headers.map((header) => header.toLowerCase())); |
| 23 | |
| 24 | const getBodyText = (body: RequestInit['body'] | null | undefined): string | undefined => { |
| 25 | if (!body) { |
| 26 | return undefined; |
| 27 | } |
| 28 | |
| 29 | if (typeof body === 'string') { |
| 30 | return body; |
| 31 | } |
| 32 | |
| 33 | if (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams) { |
| 34 | return body.toString(); |
| 35 | } |
| 36 | |
| 37 | if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) { |
| 38 | return Buffer.from(body).toString('utf8'); |
| 39 | } |
| 40 | |
| 41 | if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(body)) { |
| 42 | return Buffer.from(body.buffer, body.byteOffset, body.byteLength).toString('utf8'); |
| 43 | } |
| 44 | |
| 45 | if (typeof Buffer !== 'undefined' && Buffer.isBuffer(body)) { |
| 46 | return body.toString('utf8'); |
| 47 | } |
| 48 | |
| 49 | return undefined; |
| 50 | }; |
| 51 | |
| 52 | export function headersToHar(headers: HttpHeaders | Record<string, string>): HarHeader[] { |
| 53 | const entries: HarHeader[] = []; |