Skip to content

Commit

Permalink
http: misc ClientRequest cleanup
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 15c6187 commit 2f77596
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ function ClientRequest(options, cb) {
var port = options.port = options.port || defaultPort || 80;
var host = options.host = options.hostname || options.host || 'localhost';

if (options.setHost === undefined) {
var setHost = true;
}
var setHost = (options.setHost === undefined);

This comment has been minimized.

Copy link
@aleclarson

aleclarson Mar 19, 2018

Contributor

This should be options.setHost !== false, so you can pass a boolean and assume the Host header will be set when options.setHost is true.


self.socketPath = options.socketPath;
self.timeout = options.timeout;
Expand Down Expand Up @@ -128,7 +126,7 @@ function ClientRequest(options, cb) {
if (!headersArray) {
if (options.headers) {
var keys = Object.keys(options.headers);
for (var i = 0, l = keys.length; i < l; i++) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
self.setHeader(key, options.headers[key]);
}
Expand All @@ -154,7 +152,6 @@ function ClientRequest(options, cb) {
}

if (options.auth && !this.getHeader('Authorization')) {
//basic auth
this.setHeader('Authorization', 'Basic ' +
Buffer.from(options.auth).toString('base64'));
}
Expand Down

0 comments on commit 2f77596

Please sign in to comment.