Skip to content

Commit

Permalink
Merge pull request #120 from hasbel/proxy
Browse files Browse the repository at this point in the history
fix(binding-http): correctly use security proxy
  • Loading branch information
danielpeintner authored Jul 3, 2019
2 parents 579508c + 777df23 commit a890adc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/binding-http/src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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") {
Expand All @@ -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;
Expand Down

0 comments on commit a890adc

Please sign in to comment.