Skip to content

Commit 44c0e4f

Browse files
committed
http: avoid duplicate isArray()
PR-URL: #10654 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
1 parent e7859c2 commit 44c0e4f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/_http_client.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ function ClientRequest(options, cb) {
122122
self.once('response', cb);
123123
}
124124

125-
if (!Array.isArray(options.headers)) {
125+
var headersArray = Array.isArray(options.headers);
126+
if (!headersArray) {
126127
if (options.headers) {
127128
var keys = Object.keys(options.headers);
128129
for (var i = 0, l = keys.length; i < l; i++) {
@@ -166,7 +167,7 @@ function ClientRequest(options, cb) {
166167
self.useChunkedEncodingByDefault = true;
167168
}
168169

169-
if (Array.isArray(options.headers)) {
170+
if (headersArray) {
170171
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
171172
options.headers);
172173
} else if (self.getHeader('expect')) {

0 commit comments

Comments
 (0)