Skip to content

Commit e8e4408

Browse files
authored
Merge pull request #1524 from sunnylqm/patch-2
fix head request handler again
2 parents e9c28c6 + 5921169 commit e8e4408

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/compose.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,18 +2381,10 @@ export const composeGeneralHandler = (app: AnyElysia) => {
23812381
)
23822382
switchMap +=
23832383
`case 'HEAD':` +
2384-
`const _ht=ht[${methods.GET ?? methods.ALL}].composed(c)\n` +
2385-
`if(typeof _ht === 'function') {return _ht` +
2386-
`.then(_res=>getResponseLength(_res).then((length)=>{` +
2387-
`_res.headers.set('content-length', length)\n` +
2388-
`return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers})\n` +
2389-
'}))\n' +
2390-
`}else{` +
2391-
`return getResponseLength(_ht).then((length)=>{` +
2384+
`return Promise.resolve(ht[${methods.GET ?? methods.ALL}].composed(c)).then(_ht=>getResponseLength(_ht).then((length)=>{` +
23922385
`_ht.headers.set('content-length', length)\n` +
23932386
`return new Response(null,{status:_ht.status,statusText:_ht.statusText,headers:_ht.headers})\n` +
2394-
`})` +
2395-
`}\n`
2387+
`}))\n`
23962388

23972389
for (const [method, index] of Object.entries(methods)) {
23982390
if (method === 'ALL' || method === 'GET' || method === 'WS')

0 commit comments

Comments
 (0)