fix
This commit is contained in:
parent
fec0190ffd
commit
975b007cb1
|
|
@ -1,6 +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";
|
import { gunzipAsync, gzipAsync } from "utils/diff/diff";
|
||||||
import { decompress } from "@cloudpss/zstd";
|
import { decompress } from "@cloudpss/zstd";
|
||||||
const brotli = await brotliPromise;
|
const brotli = await brotliPromise;
|
||||||
|
|
||||||
|
|
@ -17,39 +17,39 @@ export const _ = {
|
||||||
const body = await req.arrayBuffer();
|
const body = await req.arrayBuffer();
|
||||||
const headers = {} as Record<string, string>;
|
const headers = {} as Record<string, string>;
|
||||||
req.headers.forEach((v, k) => {
|
req.headers.forEach((v, k) => {
|
||||||
// if (k.startsWith("sec-")) return;
|
if (k.startsWith("sec-")) return;
|
||||||
// if (k.startsWith("connection")) return;
|
if (k.startsWith("connection")) return;
|
||||||
// if (k.startsWith("dnt")) return;
|
if (k.startsWith("dnt")) return;
|
||||||
// if (k.startsWith("host")) return;
|
if (k.startsWith("host")) return;
|
||||||
headers[k] = v;
|
headers[k] = v;
|
||||||
});
|
});
|
||||||
|
|
||||||
return await fetch(url as any, {
|
const res = await fetch(url as any, {
|
||||||
method: req.method || "POST",
|
method: req.method || "POST",
|
||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
|
||||||
// let res_body: any = null;
|
let res_body: any = null;
|
||||||
// const res_headers: any = {};
|
const res_headers: any = {};
|
||||||
// res.headers.forEach((v, k) => {
|
res.headers.forEach((v, k) => {
|
||||||
// res_headers[k] = v;
|
res_headers[k] = v;
|
||||||
// });
|
});
|
||||||
// res_body = await res.arrayBuffer();
|
res_body = await res.arrayBuffer();
|
||||||
|
|
||||||
// let enc = res_headers["content-encoding"];
|
let enc = res_headers["content-encoding"];
|
||||||
// if (res_headers["content-encoding"] === "gzip") {
|
if (res_headers["content-encoding"] === "gzip") {
|
||||||
// res_body = await gzipAsync(new Uint8Array(res_body));
|
res_body = Bun.gunzipSync(res_body);
|
||||||
// delete res_headers["content-encoding"];
|
delete res_headers["content-encoding"];
|
||||||
// } else if (res_headers["content-encoding"] === "zstd") {
|
} else if (res_headers["content-encoding"] === "zstd") {
|
||||||
// res_body = Buffer.from(await decompress(res_body));
|
res_body = await decompress(res_body);
|
||||||
// delete res_headers["content-encoding"];
|
delete res_headers["content-encoding"];
|
||||||
// } else if (res_headers["content-encoding"] === "br") {
|
} else if (res_headers["content-encoding"] === "br") {
|
||||||
// res_body = Buffer.from(brotli.decompress(res_body));
|
res_body = brotli.decompress(res_body);
|
||||||
// delete res_headers["content-encoding"];
|
delete res_headers["content-encoding"];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return new Response(res_body, { headers: res_headers });
|
return new Response(res_body, { headers: res_headers });
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
new Response(
|
new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue