Skip to content

Commit 6add7f7

Browse files
mscdexitaloacasas
authored andcommitted
http: avoid duplicate isArray()
PR-URL: nodejs#10654 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
1 parent d9684de commit 6add7f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/_http_client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ function ClientRequest(options, cb) {
111111
self.once('response', cb);
112112
}
113113

114-
if (!Array.isArray(options.headers)) {
114+
var headersArray = Array.isArray(options.headers);
115+
if (!headersArray) {
115116
if (options.headers) {
116117
var keys = Object.keys(options.headers);
117118
for (var i = 0, l = keys.length; i < l; i++) {
@@ -155,7 +156,7 @@ function ClientRequest(options, cb) {
155156
self.useChunkedEncodingByDefault = true;
156157
}
157158

158-
if (Array.isArray(options.headers)) {
159+
if (headersArray) {
159160
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
160161
options.headers);
161162
} else if (self.getHeader('expect')) {

0 commit comments

Comments
 (0)