From fdfcf68360f1f2fce4a483ee3adaf84c3ddda065 Mon Sep 17 00:00:00 2001 From: Artem Maksimov Date: Wed, 6 Nov 2019 18:20:02 +0300 Subject: [PATCH] http: destructure primordials in lib/_http_server.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30315 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Gireesh Punathil --- lib/_http_server.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 5d8b02ef1234c8..cc3254e20ff15c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -21,7 +21,12 @@ 'use strict'; -const { Object } = primordials; +const { + Object: { + setPrototypeOf: ObjectSetPrototypeOf, + keys: ObjectKeys, + } +} = primordials; const net = require('net'); const assert = require('internal/assert'); @@ -165,8 +170,8 @@ function ServerResponse(req) { }; } } -Object.setPrototypeOf(ServerResponse.prototype, OutgoingMessage.prototype); -Object.setPrototypeOf(ServerResponse, OutgoingMessage); +ObjectSetPrototypeOf(ServerResponse.prototype, OutgoingMessage.prototype); +ObjectSetPrototypeOf(ServerResponse, OutgoingMessage); ServerResponse.prototype._finish = function _finish() { DTRACE_HTTP_SERVER_RESPONSE(this.connection); @@ -258,8 +263,8 @@ function writeHead(statusCode, reason, obj) { // Slow-case: when progressive API and header fields are passed. let k; if (obj) { - const keys = Object.keys(obj); - for (let i = 0; i < keys.length; i++) { + const keys = ObjectKeys(obj); + for (var i = 0; i < keys.length; i++) { k = keys[i]; if (k) this.setHeader(k, obj[k]); } @@ -341,8 +346,8 @@ function Server(options, requestListener) { this.maxHeadersCount = null; this.headersTimeout = 40 * 1000; // 40 seconds } -Object.setPrototypeOf(Server.prototype, net.Server.prototype); -Object.setPrototypeOf(Server, net.Server); +ObjectSetPrototypeOf(Server.prototype, net.Server.prototype); +ObjectSetPrototypeOf(Server, net.Server); Server.prototype.setTimeout = function setTimeout(msecs, callback) {