heroku-client
Advanced tools
Comparing version 2.2.2 to 2.3.0
'use strict'; | ||
var http = require('http'); | ||
var https = require('https'); | ||
@@ -7,2 +8,3 @@ var tunnel = require('tunnel-agent'); | ||
var q = require('q'); | ||
var URL = require('./url'); | ||
var pjson = require('../package.json'); | ||
@@ -24,3 +26,6 @@ | ||
} | ||
this.host = options.host || 'api.heroku.com'; | ||
var url = URL(options.host || 'https://api.heroku.com'); | ||
this.host = url.host; | ||
this.port = url.port; | ||
this.secure = url.secure; | ||
this.partial = options.partial; | ||
@@ -35,3 +40,9 @@ this.callback = callback; | ||
if (process.env.HEROKU_HTTP_PROXY_HOST) { | ||
this.agent = tunnel.httpsOverHttp({ | ||
var tunnelFunc; | ||
if (this.secure) { | ||
tunnelFunc = tunnel.httpsOverHttp; | ||
} else { | ||
tunnelFunc = tunnel.httpOverHttp; | ||
} | ||
this.agent = tunnelFunc({ | ||
proxy: { | ||
@@ -43,3 +54,7 @@ host: process.env.HEROKU_HTTP_PROXY_HOST, | ||
} else { | ||
this.agent = new https.Agent({ maxSockets: Number(process.env.HEROKU_CLIENT_MAX_SOCKETS) || 5000 }); | ||
if (this.secure) { | ||
this.agent = new https.Agent({ maxSockets: Number(process.env.HEROKU_CLIENT_MAX_SOCKETS) || 5000 }); | ||
} else { | ||
this.agent = new http.Agent({ maxSockets: Number(process.env.HEROKU_CLIENT_MAX_SOCKETS) || 5000 }); | ||
} | ||
} | ||
@@ -97,3 +112,3 @@ } | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: this.options.path, | ||
@@ -110,3 +125,7 @@ auth: this.options.auth || ':' + this.options.token, | ||
req = https.request(requestOptions, this.handleResponse.bind(this)); | ||
if (this.secure) { | ||
req = https.request(requestOptions, this.handleResponse.bind(this)); | ||
} else { | ||
req = http.request(requestOptions, this.handleResponse.bind(this)); | ||
} | ||
@@ -113,0 +132,0 @@ this.logRequest(req); |
{ | ||
"name": "heroku-client", | ||
"description": "A wrapper for the Heroku v3 API", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"author": "Jonathan Clem", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -140,3 +140,4 @@ 'use strict'; | ||
makeRequest('/apps', { host: 'api.example.com' }, function() { | ||
expect(https.request.mostRecentCall.args[0].host).toEqual('api.example.com'); | ||
expect(http.request.mostRecentCall.args[0].host).toEqual('api.example.com'); | ||
expect(http.request.mostRecentCall.args[0].port).toEqual(80); | ||
done(); | ||
@@ -143,0 +144,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314565
19
9931
5
4