http.proxyAuthorization setting

fixes #6480
This commit is contained in:
Joao Moreno
2016-08-31 09:52:19 +02:00
parent f7a6d19c07
commit df2bf8b841
2 changed files with 13 additions and 0 deletions
@@ -23,6 +23,7 @@ export interface IHTTPConfiguration {
http?: {
proxy?: string;
proxyStrictSSL?: boolean;
proxyAuthorization?: string;
};
}
@@ -42,6 +43,11 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration)
type: 'boolean',
default: true,
description: localize('strictSSL', "Whether the proxy server certificate should be verified against the list of supplied CAs.")
},
'http.proxyAuthorization': {
type: 'string',
default: null,
description: localize('proxyAuthorization', "The value to send as the 'Proxy-Authorization' header for every network request.")
}
}
});
@@ -6,6 +6,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable } from 'vs/base/common/lifecycle';
import { assign } from 'vs/base/common/objects';
import { IRequestOptions, IRequestContext, request } from 'vs/base/node/request';
import { getProxyAgent } from 'vs/base/node/proxy';
import { IRequestService, IHTTPConfiguration } from 'vs/platform/request/common/request';
@@ -21,6 +22,7 @@ export class RequestService implements IRequestService {
private proxyUrl: string;
private strictSSL: boolean;
private authorization: string;
private disposables: IDisposable[] = [];
constructor(
@@ -37,6 +39,7 @@ export class RequestService implements IRequestService {
private configure(config: IHTTPConfiguration) {
this.proxyUrl = config.http && config.http.proxy;
this.strictSSL = config.http && config.http.proxyStrictSSL;
this.authorization = config.http && config.http.proxyAuthorization;
}
request(options: IRequestOptions): TPromise<IRequestContext> {
@@ -45,6 +48,10 @@ export class RequestService implements IRequestService {
options.agent = getProxyAgent(options.url, { proxyUrl, strictSSL });
}
if (this.authorization) {
options.headers = assign(options.headers || {}, { 'Proxy-Authorization': this.authorization });
}
return request(options);
}
}