From a9af80ae2d8852fb6741feabb830e6596fa3e23e Mon Sep 17 00:00:00 2001 From: weilixiong Date: Sun, 17 May 2026 10:32:20 +0800 Subject: [PATCH 1/2] fix(#150): auto-register HEAD route for GET routes --- src/http/routing/route-registry.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/http/routing/route-registry.ts b/src/http/routing/route-registry.ts index ea03379..528363c 100644 --- a/src/http/routing/route-registry.ts +++ b/src/http/routing/route-registry.ts @@ -245,6 +245,19 @@ export class RouteRegistry { metadata, }); + // Auto-register HEAD route for GET routes (RFC 9110 §9.3.2) + if (normalizedMethod === 'GET') { + this.routes.set(`HEAD:${path}`, { + method: 'HEAD', + path, + uwsPath, + pattern, + paramNames, + isComplex, + handler, + metadata, + }); + } // Get the uWS method function const uwsMethodFn = this.uwsApp[uwsMethod as keyof uWS.TemplatedApp] as any; From 1985ff34a63efe012052b45856f98000b605a069 Mon Sep 17 00:00:00 2001 From: weilixiong Date: Sun, 17 May 2026 10:34:47 +0800 Subject: [PATCH 2/2] fix(#151): suppress response body for HEAD requests --- src/http/core/response.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/http/core/response.ts b/src/http/core/response.ts index 46d8b8f..ae6f02f 100644 --- a/src/http/core/response.ts +++ b/src/http/core/response.ts @@ -1291,6 +1291,11 @@ export class UwsResponse extends Writable { finalBody = String(body); } + // RFC 9110 §9.3.2: HEAD responses must have identical headers to GET but no body. + if (this.req?.method === 'HEAD') { + finalBody = undefined; + } + this.sending = true; // Apply compression if configured and body is present