@@ -43,6 +43,7 @@ var https = require('https'),
4343 this . timeout = params . timeout ;
4444 this . apiTimeDiff = params . apiTimeDiff || null ;
4545 this . endpoint = params . endpoint || null ;
46+ this . httpsAgent = params . agent || null ;
4647
4748 // Preconfigured API endpoints
4849 if ( this . endpoint ) {
@@ -103,6 +104,10 @@ var https = require('https'),
103104 path : this . basePath + path
104105 } ;
105106
107+ if ( this . httpsAgent ) {
108+ request . agent = this . httpsAgent ;
109+ }
110+
106111 // Fetch only selected APIs
107112 if ( path === '/' ) {
108113 return async . each (
@@ -519,6 +524,10 @@ var https = require('https'),
519524 'X-Ovh-Application' : this . appKey ,
520525 } ;
521526
527+ if ( this . httpsAgent ) {
528+ options . agent = this . httpsAgent ;
529+ }
530+
522531 // Remove undefined values
523532 for ( var k in params ) {
524533 if ( params . hasOwnProperty ( k ) && typeof ( params [ k ] ) === 'undefined' ) {
@@ -654,6 +663,17 @@ var https = require('https'),
654663 return '$1$' + crypto . createHash ( 'sha1' ) . update ( s . join ( '+' ) ) . digest ( 'hex' ) ;
655664 } ;
656665
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+
657677 module . exports = function ( params ) {
658678 return new Ovh ( params || { } ) ;
659679 } ;
0 commit comments