Skip to content

Commit 4a7d2b7

Browse files
committed
https-proxy-agent: update to the "agent-base" v1 API
1 parent 9ae8e01 commit 4a7d2b7

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

https-proxy-agent.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ function HttpsProxyAgent (opts) {
2828
if ('string' == typeof opts) opts = url.parse(opts);
2929
if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
3030
debug('creating new HttpsProxyAgent instance: %j', opts);
31-
32-
Agent.call(this);
31+
Agent.call(this, connect);
3332

3433
var proxy = clone(opts, {});
35-
this.secureProxy = proxy.protocol && proxy.protocol == 'https:';
36-
this.secureEndpoint = opts.secureEndpoint !== false; // `true` by default
37-
if (!this.secureEndpoint) {
38-
this.defaultPort = 80;
39-
}
34+
35+
// if `true`, then connect to the proxy server over TLS. defaults to `false`.
36+
this.secureProxy = proxy.protocol ? proxy.protocol == 'https:' : false;
37+
38+
// if `true`, then connect to the destination endpoint over TLS, defaults to `true`
39+
this.secureEndpoint = opts.secureEndpoint !== false;
4040

4141
// prefer `hostname` over `host`, and set the `port` if needed
4242
proxy.host = proxy.hostname || proxy.host;
@@ -54,18 +54,13 @@ function HttpsProxyAgent (opts) {
5454
inherits(HttpsProxyAgent, Agent);
5555

5656
/**
57-
* Default port to connect to.
58-
*/
59-
60-
Agent.prototype.defaultPort = 443;
61-
62-
/**
63-
* Initiates a TCP connection to the specified HTTP proxy server.
57+
* Called when the node-core HTTP client library is creating a new HTTP request.
6458
*
65-
* @api protected
59+
* @api public
6660
*/
6761

68-
HttpsProxyAgent.prototype.createConnection = function (opts, fn) {
62+
function connect (req, opts, fn) {
63+
6964
var socket;
7065
if (this.secureProxy) {
7166
socket = tls.connect(this.proxy);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"url": "https://github.com/TooTallNate/node-https-proxy-agent/issues"
2323
},
2424
"dependencies": {
25-
"agent-base": "~0.0.1",
25+
"agent-base": "~1.0.1",
2626
"debug": "~0.7.2"
2727
},
2828
"devDependencies": {

0 commit comments

Comments
 (0)