From 072e53b10e2ffc642bfe3b845771a2507fc5e3d7 Mon Sep 17 00:00:00 2001 From: Brian White Date: Fri, 6 Jan 2017 03:13:33 -0500 Subject: [PATCH] http: avoid duplicate isArray() PR-URL: https://github.com/nodejs/node/pull/10654 Reviewed-By: James M Snell Reviewed-By: Fedor Indutny --- lib/_http_client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index a8447158201d0f..a8dd6c53e8e7cb 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -113,7 +113,8 @@ function ClientRequest(options, cb) { self.once('response', cb); } - if (!Array.isArray(options.headers)) { + var headersArray = Array.isArray(options.headers); + if (!headersArray) { if (options.headers) { var keys = Object.keys(options.headers); for (var i = 0, l = keys.length; i < l; i++) { @@ -157,7 +158,7 @@ function ClientRequest(options, cb) { self.useChunkedEncodingByDefault = true; } - if (Array.isArray(options.headers)) { + if (headersArray) { self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', options.headers); } else if (self.getHeader('expect')) {