wip fix
This commit is contained in:
parent
68415bb8e0
commit
b3958b5a00
|
|
@ -1,5 +1,6 @@
|
||||||
import brotliPromise from "brotli-wasm";
|
import brotliPromise from "brotli-wasm";
|
||||||
import { apiContext } from "service-srv";
|
import { apiContext } from "service-srv";
|
||||||
|
import { gzipAsync } from "utils/diff/diff";
|
||||||
|
|
||||||
const brotli = await brotliPromise;
|
const brotli = await brotliPromise;
|
||||||
|
|
||||||
|
|
@ -23,11 +24,24 @@ export const _ = {
|
||||||
headers[k] = v;
|
headers[k] = v;
|
||||||
});
|
});
|
||||||
|
|
||||||
return await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: req.method || "POST",
|
method: req.method || "POST",
|
||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let res_body: any = null;
|
||||||
|
const res_headers: any = {};
|
||||||
|
res.headers.forEach((v, k) => {
|
||||||
|
res_headers[k] = v;
|
||||||
|
});
|
||||||
|
res_body = await res.arrayBuffer();
|
||||||
|
if (res_headers["content-encoding"] === "gzip") {
|
||||||
|
res_body = await gzipAsync(new Uint8Array(res_body));
|
||||||
|
} else {
|
||||||
|
delete res_headers["content-encoding"];
|
||||||
|
}
|
||||||
|
return new Response(res_body, { headers: res_headers });
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
new Response(
|
new Response(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue