( request: HttpClientRequest.HttpClientRequest, headers: Headers, body: BodyInit | null | undefined, )
| 87 | Object.fromEntries(headers.entries()); |
| 88 | |
| 89 | const applyBody = async ( |
| 90 | request: HttpClientRequest.HttpClientRequest, |
| 91 | headers: Headers, |
| 92 | body: BodyInit | null | undefined, |
| 93 | ): Promise<HttpClientRequest.HttpClientRequest> => { |
| 94 | if (body == null) return request; |
| 95 | const contentType = headers.get("content-type") ?? undefined; |
| 96 | if (typeof body === "string") return HttpClientRequest.bodyText(request, body, contentType); |
| 97 | if (body instanceof URLSearchParams) { |
| 98 | return HttpClientRequest.bodyText( |
| 99 | request, |
| 100 | body.toString(), |
| 101 | contentType ?? "application/x-www-form-urlencoded;charset=UTF-8", |
| 102 | ); |
| 103 | } |
| 104 | if (body instanceof Uint8Array) |
| 105 | return HttpClientRequest.bodyUint8Array(request, body, contentType); |
| 106 | if (body instanceof ArrayBuffer) { |
| 107 | return HttpClientRequest.bodyUint8Array(request, new Uint8Array(body), contentType); |
| 108 | } |
| 109 | const bytes = new Uint8Array(await new Response(body).arrayBuffer()); |
| 110 | return HttpClientRequest.bodyUint8Array(request, bytes, contentType); |
| 111 | }; |
| 112 | |
| 113 | const abortError = (signal: AbortSignal): unknown => { |
| 114 | if (signal.reason !== undefined) return signal.reason; |
no test coverage detected