@@ -43,6 +43,7 @@ var https = require('https'),
43
43
this . timeout = params . timeout ;
44
44
this . apiTimeDiff = params . apiTimeDiff || null ;
45
45
this . endpoint = params . endpoint || null ;
46
+ this . httpsAgent = params . agent || null ;
46
47
47
48
// Preconfigured API endpoints
48
49
if ( this . endpoint ) {
@@ -103,6 +104,10 @@ var https = require('https'),
103
104
path : this . basePath + path
104
105
} ;
105
106
107
+ if ( this . httpsAgent ) {
108
+ request . agent = this . httpsAgent ;
109
+ }
110
+
106
111
// Fetch only selected APIs
107
112
if ( path === '/' ) {
108
113
return async . each (
@@ -519,6 +524,10 @@ var https = require('https'),
519
524
'X-Ovh-Application' : this . appKey ,
520
525
} ;
521
526
527
+ if ( this . httpsAgent ) {
528
+ options . agent = this . httpsAgent ;
529
+ }
530
+
522
531
// Remove undefined values
523
532
for ( var k in params ) {
524
533
if ( params . hasOwnProperty ( k ) && typeof ( params [ k ] ) === 'undefined' ) {
@@ -654,6 +663,17 @@ var https = require('https'),
654
663
return '$1$' + crypto . createHash ( 'sha1' ) . update ( s . join ( '+' ) ) . digest ( 'hex' ) ;
655
664
} ;
656
665
666
+ /**
667
+ * Change the custom HTTPS agent used for reaching the OVH servers
668
+ *
669
+ * @param {Object } httpsAgent: the custom HTTPS agent
670
+ */
671
+ Ovh . prototype . setCustomHTTPSAgent = function ( httpsAgent ) {
672
+ if ( typeof ( httpsAgent ) === 'undefined' || typeof ( httpsAgent ) === 'object' ) {
673
+ this . httpsAgent = httpsAgent ;
674
+ }
675
+ }
676
+
657
677
module . exports = function ( params ) {
658
678
return new Ovh ( params || { } ) ;
659
679
} ;
0 commit comments