From c972ce200e1fd7519e65bbcb978392d517871b5e Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Sat, 25 Apr 2020 16:46:10 +0530 Subject: [PATCH] http2: comment on usage of `Object.create(null)` Refs: https://github.com/nodejs/node/issues/29829 PR-URL: https://github.com/nodejs/node/pull/33183 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- lib/internal/http2/compat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 3abe9ba2ac6f82..851fec4b3a6ae5 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -287,6 +287,9 @@ class Http2ServerRequest extends Readable { closed: false, didRead: false, }; + // Headers in HTTP/1 are not initialized using Object.create(null) which, + // although preferable, would simply break too much code. Ergo header + // initialization using Object.create(null) in HTTP/2 is intentional. this[kHeaders] = headers; this[kRawHeaders] = rawHeaders; this[kTrailers] = {};