export async function requestBodyForHttp1(body, signal, maxBytes = 25 * 1024 * 1024) { if (!body || typeof body.getReader !== "function") return body; const reader = body.getReader(), chunks = []; let size = 0; try { while (true) { if (signal?.aborted) throw new DOMException("Aborted", "AbortError"); const {done, value} = await reader.read(); if (signal?.aborted) throw new DOMException("Aborted", "AbortError"); if (done) break; size += value.byteLength; if (size > maxBytes) throw new Error("This prototype supports uploads up to 25 MB."); chunks.push(value); } return new Blob(chunks); } catch (error) { try { await reader.cancel(); } catch { /* preserve original error */ } throw error; } finally { reader.releaseLock(); } }