mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-21 15:49:15 +01:00
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user