From 777df23ebf70b84481f37118ea11e4a17189d725 Mon Sep 17 00:00:00 2001 From: Hassib Belhaj Date: Sun, 23 Jun 2019 21:45:45 +0200 Subject: [PATCH] fix(binding-http): correctly use security proxy Signed-off-by: Hassib Belhaj --- packages/binding-http/src/http-client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/binding-http/src/http-client.ts b/packages/binding-http/src/http-client.ts index bd1cf447a..9cbadc3a3 100644 --- a/packages/binding-http/src/http-client.ts +++ b/packages/binding-http/src/http-client.ts @@ -42,7 +42,7 @@ export default class HttpClient implements ProtocolClient { // config proxy by client side (not from TD) if (config!==null && config.proxy && config.proxy.href) { - this.proxyOptions = this.uriToOptions(config.proxy.href); + this.proxyOptions = this.uriToOptions(config.proxy.href, true); if (config.proxy.scheme === "basic") { if (!config.proxy.hasOwnProperty("username") || !config.proxy.hasOwnProperty("password")) console.warn(`HttpClient client configured for basic proxy auth, but no username/password given`); @@ -286,7 +286,7 @@ export default class HttpClient implements ProtocolClient { console.info(`HttpClient overriding client-side proxy with security proxy '${security.proxy}`); } - this.proxyOptions = this.uriToOptions(security.proxy); + this.proxyOptions = this.uriToOptions(security.proxy, true); // TODO support for different credentials at proxy and server (e.g., credentials.username vs credentials.proxy.username) if (security.scheme == "basic") { @@ -308,12 +308,12 @@ export default class HttpClient implements ProtocolClient { return true; } - private uriToOptions(uri: string): https.RequestOptions { + private uriToOptions(uri: string, ignoreProxy=false): https.RequestOptions { let requestUri = url.parse(uri); let options: https.RequestOptions = {}; options.agent = this.agent; - if (this.proxyOptions != null) { + if (this.proxyOptions != null && ignoreProxy === false) { options.hostname = this.proxyOptions.hostname; options.port = this.proxyOptions.port; options.path = uri;