http: improve writeEarlyHints by avoiding for-of loop

PR-URL: https://github.com/nodejs/node/pull/59958
Refs: https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md#unsafe-array-iteration
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Haram Jeong 2025-10-06 18:11:45 +09:00 committed by GitHub
parent 0c1fb986a0
commit 5b3c4b37f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -331,7 +331,9 @@ ServerResponse.prototype.writeEarlyHints = function writeEarlyHints(hints, cb) {
head += 'Link: ' + link + '\r\n';
for (const key of ObjectKeys(hints)) {
const keys = ObjectKeys(hints);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key !== 'link') {
head += key + ': ' + hints[key] + '\r\n';
}