From b2813a7547fd416fb0c038ae3d13bc954d5ad23d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 26 Mar 2025 10:22:58 +0100 Subject: [PATCH] fix: add methods Translate method number to string --- src/fetch/index.ts | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/fetch/index.ts b/src/fetch/index.ts index 4f89c38..168d963 100644 --- a/src/fetch/index.ts +++ b/src/fetch/index.ts @@ -9,14 +9,44 @@ import { type Uint8ArrayList } from 'uint8arraylist' interface Fetch { (req: Request): Promise } -const METHOD_GET = 1 +const METHODS = [ + 'DELETE', + 'GET', + 'HEAD', + 'POST', + 'PUT', + 'CONNECT', + 'OPTIONS', + 'TRACE', + 'COPY', + 'LOCK', + 'MKCOL', + 'MOVE', + 'PROPFIND', + 'PROPPATCH', + 'SEARCH', + 'UNLOCK', + 'BIND', + 'REBIND', + 'UNBIND', + 'ACL', + 'REPORT', + 'MKACTIVITY', + 'CHECKOUT', + 'MERGE', + 'M-SEARCH', + 'NOTIFY', + 'SUBSCRIBE', + 'UNSUBSCRIBE', + 'PATCH', + 'PURGE', + 'MKCALENDAR', + 'LINK', + 'UNLINK' +] function getStringMethod (method: number): string { - if (method === 1) { - return 'GET' - } - - return 'UNKNOWN' + return METHODS[method] ?? 'UNKNOWN' } interface Duplex> { @@ -129,7 +159,7 @@ export function readHTTPMsg (expectRequest: boolean, r: Duplex