Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
http: make globalAgent of http and https as overridable properties
The `http.globalAgent` and `https.globalAgent` previously cannot be
overridden directly by reassigning new a value.

By exposing the `globalAgent`s of `http` and `https`, now it can be
reassigned by:

    http.globalAgent = new MyAgent();
    https.globalAgent = new MySecureAgent();
  • Loading branch information
Dhi Aurrahman committed Oct 31, 2016
commit 489a158f771655c14b21d98779aa2ac6e8e1afb0
1 change: 1 addition & 0 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const client = require('_http_client');
const ClientRequest = exports.ClientRequest = client.ClientRequest;

exports.request = function request(options, cb) {
options._defaultAgent = options._defaultAgent || exports.globalAgent || agent.globalAgent;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long line. make test would have caught this, it runs make lint.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK @bnoordhuis will fix this.

return new ClientRequest(options, cb);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ exports.request = function(options, cb) {
} else {
options = util._extend({}, options);
}
options._defaultAgent = globalAgent;
options._defaultAgent = exports.globalAgent || globalAgent;
return http.request(options, cb);
};

Expand Down