fix
This commit is contained in:
parent
27eb527cce
commit
5e90332489
|
|
@ -54,6 +54,7 @@ export const createResponse = (
|
||||||
cache_accept?: string;
|
cache_accept?: string;
|
||||||
headers?: any;
|
headers?: any;
|
||||||
res?: any;
|
res?: any;
|
||||||
|
br?: boolean;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
const status =
|
const status =
|
||||||
|
|
@ -63,7 +64,7 @@ export const createResponse = (
|
||||||
const headers = { ...(opt?.headers || {}) } as Record<string, string>;
|
const headers = { ...(opt?.headers || {}) } as Record<string, string>;
|
||||||
if (opt?.cache_accept) {
|
if (opt?.cache_accept) {
|
||||||
let cached = false;
|
let cached = false;
|
||||||
if (opt.cache_accept.toLowerCase().includes("br")) {
|
if (opt?.br && opt.cache_accept.toLowerCase().includes("br")) {
|
||||||
const content_hash = simpleHash(content);
|
const content_hash = simpleHash(content);
|
||||||
|
|
||||||
if (!g.cache.br[content_hash]) {
|
if (!g.cache.br[content_hash]) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export const serveWeb = async (arg: {
|
||||||
const type = mime.getType(arg.pathname);
|
const type = mime.getType(arg.pathname);
|
||||||
return createResponse(arg.content, {
|
return createResponse(arg.content, {
|
||||||
cache_accept: arg.cache_accept,
|
cache_accept: arg.cache_accept,
|
||||||
|
br: true,
|
||||||
headers: !type ? undefined : { "content-type": type },
|
headers: !type ? undefined : { "content-type": type },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue