Skip to content

Commit

Permalink
http: avoid duplicate isArray()
Browse files Browse the repository at this point in the history
PR-URL: #10654
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
mscdex committed Jan 13, 2017
1 parent dab22b5 commit 15c6187
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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++) {
Expand Down Expand Up @@ -168,7 +169,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')) {
Expand Down

0 comments on commit 15c6187

Please sign in to comment.