import { fetch } from "../adapter"; import { Requester } from "../type/Requester"; // 可以被替换的 请求器 export const fetchRequester: Requester = async ( url, method, headers, body, { autoRedirect = true } ) => { return fetch(url.toString(), { method, headers, body, // 如果这次出现了 cookie 字段,那么就发送 cookie credentials: headers.has("cookie") ? "include" : "omit", redirect: autoRedirect ? "follow" : "manual", }).then(async (res) => { const { status, headers } = res; const body = await res.arrayBuffer(); return { status, headers, data: { type: "arrayBuffer", body }, }; }); };