From 44c0e4f1ad694301efe0f323625bf56c7d15efc8 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 bf77e7e0ce964e..1e054821d3a48c 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -122,7 +122,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++) { @@ -166,7 +167,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')) {