diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 9a920adeee..948a3527bd 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1409,7 +1409,7 @@ ServerResponse.prototype.hasHeader = function ( this: ServerResponse, name: string, ) { - return Object.hasOwn(this._headers, name); + return Object.hasOwn(this._headers, StringPrototypeToLowerCase(name)); }; ServerResponse.prototype.writeHead = function ( diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index 2b3b8f509f..31ac6bee25 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -1151,6 +1151,7 @@ Deno.test("[node/http] ServerResponse header names case insensitive", async () = const { promise, resolve } = Promise.withResolvers(); const server = http.createServer((_req, res) => { res.setHeader("Content-Length", "12345"); + assert(res.hasHeader("Content-Length")); res.removeHeader("content-length"); assertEquals(res.getHeader("Content-Length"), undefined); assert(!res.hasHeader("Content-Length"));