import{RequestBodySizeLimitError as t}from"../errors/request-body-size-limit.js";import{readStreamWithSizeLimit as o}from"./read-stream-with-size-limit.js";const i=5;async function n(e){return e?o({stream:e,maxSizeMB:i,onSizeExceededErrorHandler:()=>{throw new t(`Request body size exceeded limit of ${i} MB.`)}}):null}function d(e){return Object.fromEntries(e.entries())}async function c(e){const r=await n(e.body);return{method:e.method,url:e.url,headers:d(e.headers),body:Buffer.isBuffer(r)?r.toString():r,bodyUsed:e.bodyUsed,cache:e.cache,credentials:e.credentials,destination:e.destination,integrity:e.integrity,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy}}export{i as MAX_REQUEST_BODY_SIZE_MB,c as serializeRequest};
