Skip to content

Commit 5b3c4b3

Browse files
authored
http: improve writeEarlyHints by avoiding for-of loop
PR-URL: #59958 Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 0c1fb98 commit 5b3c4b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/_http_server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ ServerResponse.prototype.writeEarlyHints = function writeEarlyHints(hints, cb) {
331331

332332
head += 'Link: ' + link + '\r\n';
333333

334-
for (const key of ObjectKeys(hints)) {
334+
const keys = ObjectKeys(hints);
335+
for (let i = 0; i < keys.length; i++) {
336+
const key = keys[i];
335337
if (key !== 'link') {
336338
head += key + ': ' + hints[key] + '\r\n';
337339
}

0 commit comments

Comments
 (0)