mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
fix(node/http): casing ignored in ServerResponse.hasHeader() (#27105)
We didn't respect casing when checking if a HTTP header is present in Node's `ServerResponse.hasHeader()`. This lead to us returning incorrect results when the header was present. Koa assumed that the `Content-Type` header wasn't present when it actually was and defaulted to a different `Content-Type` value. Fixes https://github.com/denoland/deno/issues/27101
This commit is contained in:
parent
93adf37bdf
commit
9bc36aa79b
2 changed files with 2 additions and 1 deletions
|
@ -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 (
|
||||
|
|
|
@ -1151,6 +1151,7 @@ Deno.test("[node/http] ServerResponse header names case insensitive", async () =
|
|||
const { promise, resolve } = Promise.withResolvers<void>();
|
||||
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"));
|
||||
|
|
Loading…
Reference in a new issue