@@ -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) {
5454inherits ( 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 ) ;
0 commit comments