Skip to content

Commit fcc3070

Browse files
committed
http2/compat: make req.trailers have a null prototype
In HTTP/2 compatibility mode, make request trailers have a null prototype, matching the behavior of regular headers and trailers.
1 parent 0a071d8 commit fcc3070

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/internal/http2/compat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class Http2ServerRequest extends Readable {
319319
// initialization using Object.create(null) in HTTP/2 is intentional.
320320
this[kHeaders] = headers;
321321
this[kRawHeaders] = rawHeaders;
322-
this[kTrailers] = {};
322+
this[kTrailers] = { __proto__: null };
323323
this[kRawTrailers] = [];
324324
this[kStream] = stream;
325325
this[kAborted] = false;

test/parallel/test-http2-compat-serverrequest-trailers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ server.listen(0, common.mustCall(function() {
2222
request.on('data', common.mustCallAtLeast((chunk) => data += chunk));
2323
request.on('end', common.mustCall(() => {
2424
const trailers = request.trailers;
25+
assert.strictEqual(Object.getPrototypeOf(trailers), null);
2526
for (const [name, value] of Object.entries(expectedTrailers)) {
2627
assert.strictEqual(trailers[name], value);
2728
}

0 commit comments

Comments
 (0)