(object, keepalive = false)
| 6703 | } |
| 6704 | }); |
| 6705 | function extractBody(object, keepalive = false) { |
| 6706 | let stream = null; |
| 6707 | let controller = null; |
| 6708 | if (webidl.is.ReadableStream(object)) { |
| 6709 | stream = object; |
| 6710 | } else if (webidl.is.Blob(object)) { |
| 6711 | stream = object.stream(); |
| 6712 | } else { |
| 6713 | stream = new ReadableStream({ |
| 6714 | pull() { |
| 6715 | }, |
| 6716 | start(c) { |
| 6717 | controller = c; |
| 6718 | }, |
| 6719 | cancel() { |
| 6720 | }, |
| 6721 | type: "bytes" |
| 6722 | }); |
| 6723 | } |
| 6724 | assert(webidl.is.ReadableStream(stream)); |
| 6725 | let action = null; |
| 6726 | let source = null; |
| 6727 | let length = null; |
| 6728 | let type = null; |
| 6729 | if (typeof object === "string") { |
| 6730 | source = object; |
| 6731 | type = "text/plain;charset=UTF-8"; |
| 6732 | } else if (webidl.is.URLSearchParams(object)) { |
| 6733 | source = object.toString(); |
| 6734 | type = "application/x-www-form-urlencoded;charset=UTF-8"; |
| 6735 | } else if (webidl.is.BufferSource(object)) { |
| 6736 | source = webidl.util.getCopyOfBytesHeldByBufferSource(object); |
| 6737 | } else if (webidl.is.FormData(object)) { |
| 6738 | const boundary = getFormDataBoundary(object); |
| 6739 | const prefix = `--${boundary}\r |
| 6740 | Content-Disposition: form-data`; |
| 6741 | const formdataEscape = /* @__PURE__ */ __name((str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), "formdataEscape"); |
| 6742 | const normalizeLinefeeds = /* @__PURE__ */ __name((value) => value.replace(/\r?\n|\r/g, "\r\n"), "normalizeLinefeeds"); |
| 6743 | const blobParts = []; |
| 6744 | const rn = new Uint8Array([13, 10]); |
| 6745 | length = 0; |
| 6746 | let hasUnknownSizeValue = false; |
| 6747 | for (const [name, value] of object) { |
| 6748 | if (typeof value === "string") { |
| 6749 | const chunk2 = textEncoder.encode(prefix + `; name="${formdataEscape(normalizeLinefeeds(name))}"\r |
| 6750 | \r |
| 6751 | ${normalizeLinefeeds(value)}\r |
| 6752 | `); |
| 6753 | blobParts.push(chunk2); |
| 6754 | length += chunk2.byteLength; |
| 6755 | } else { |
| 6756 | const chunk2 = textEncoder.encode(`${prefix}; name="${formdataEscape(normalizeLinefeeds(name))}"` + (value.name ? `; filename="${formdataEscape(value.name)}"` : "") + `\r |
| 6757 | Content-Type: ${value.type || "application/octet-stream"}\r |
| 6758 | \r |
| 6759 | `); |
| 6760 | blobParts.push(chunk2, value, rn); |
| 6761 | if (typeof value.size === "number") { |
| 6762 | length += chunk2.byteLength + value.size + rn.byteLength; |
no test coverage detected
searching dependent graphs…