From c5a97b566a2a17e536234ff38def785aa8b82415 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Sun, 2 Nov 2025 22:13:25 +0800 Subject: [PATCH 1/2] fix head request --- src/compose.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compose.ts b/src/compose.ts index 11c333e0..0e4c838a 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -2378,11 +2378,10 @@ export const composeGeneralHandler = (app: AnyElysia) => { ) switchMap += `case 'HEAD':` + - `const _res=ht[${methods.GET ?? methods.ALL}].composed(c)\n` + - 'return getResponseLength(_res).then((length)=>{' + + `return ht[${methods.GET ?? methods.ALL}].composed(c).then(_res => getResponseLength(_res).then((length)=>{` + `_res.headers.set('content-length', length)\n` + `return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers})\n` + - '})\n' + '}))\n' for (const [method, index] of Object.entries(methods)) { if (method === 'ALL' || method === 'GET' || method === 'WS') From 2e8b82fd49be246394972a18eeb078e9ed1924d1 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Sun, 2 Nov 2025 22:20:21 +0800 Subject: [PATCH 2/2] Update compose.ts --- src/compose.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compose.ts b/src/compose.ts index 0e4c838a..f4472e47 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -2378,7 +2378,7 @@ export const composeGeneralHandler = (app: AnyElysia) => { ) switchMap += `case 'HEAD':` + - `return ht[${methods.GET ?? methods.ALL}].composed(c).then(_res => getResponseLength(_res).then((length)=>{` + + `return ht[${methods.GET ?? methods.ALL}].composed(c).then(_res=>getResponseLength(_res).then((length)=>{` + `_res.headers.set('content-length', length)\n` + `return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers})\n` + '}))\n'