diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index 4e1729e01c..39127b1ecf 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -508,6 +508,14 @@ function guardFromHeaders(headers) { return headers[_guard]; } +/** + * @param {Headers} headers + * @returns {[string, string][]} + */ +function headersEntries(headers) { + return headers[_iterableHeaders]; +} + export { fillHeaders, getDecodeSplitHeader, @@ -515,5 +523,6 @@ export { guardFromHeaders, headerListFromHeaders, Headers, + headersEntries, headersFromHeaderList, }; diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 2d80c2cd99..609a046ac8 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -55,6 +55,7 @@ import { import { getTimerDuration } from "ext:deno_node/internal/timers.mjs"; import { serve, upgradeHttpRaw } from "ext:deno_http/00_serve.js"; import { createHttpClient } from "ext:deno_fetch/22_http_client.js"; +import { headersEntries } from "ext:deno_fetch/20_headers.js"; import { timerId } from "ext:deno_web/03_abort_signal.js"; import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js"; import { TcpConn } from "ext:deno_net/01_net.js"; @@ -1486,7 +1487,12 @@ export class IncomingMessageForServer extends NodeReadable { get headers() { if (!this.#headers) { - this.#headers = Object.fromEntries(this.#req.headers.entries()); + this.#headers = {}; + const entries = headersEntries(this.#req.headers); + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + this.#headers[entry[0]] = entry[1]; + } } return this.#headers; }