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