mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Merge from master
This commit is contained in:
@@ -2,21 +2,20 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IRequestOptions, IRequestContext } from 'vs/base/node/request';
|
||||
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export const IRequestService = createDecorator<IRequestService>('requestService2');
|
||||
|
||||
export interface IRequestService {
|
||||
_serviceBrand: any;
|
||||
|
||||
request(options: IRequestOptions): TPromise<IRequestContext>;
|
||||
request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext>;
|
||||
}
|
||||
|
||||
export interface IHTTPConfiguration {
|
||||
@@ -48,6 +47,17 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration)
|
||||
type: ['null', 'string'],
|
||||
default: null,
|
||||
description: localize('proxyAuthorization', "The value to send as the 'Proxy-Authorization' header for every network request.")
|
||||
},
|
||||
'http.proxySupport': {
|
||||
type: 'string',
|
||||
enum: ['off', 'on', 'override'],
|
||||
enumDescriptions: [
|
||||
localize('proxySupportOff', "Disable proxy support for extensions."),
|
||||
localize('proxySupportOn', "Enable proxy support for extensions."),
|
||||
localize('proxySupportOverride', "Enable proxy support for extensions, override request options."),
|
||||
],
|
||||
default: 'off',
|
||||
description: localize('proxySupport', "Experimental setting: Use the proxy support for extensions.")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
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, IRequestFunction, request } from 'vs/base/node/request';
|
||||
@@ -12,6 +10,7 @@ import { getProxyAgent } from 'vs/base/node/proxy';
|
||||
import { IRequestService, IHTTPConfiguration } from 'vs/platform/request/node/request';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
/**
|
||||
* This service exposes the `request` API, while using the global
|
||||
@@ -21,9 +20,9 @@ export class RequestService implements IRequestService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private proxyUrl: string;
|
||||
private proxyUrl?: string;
|
||||
private strictSSL: boolean;
|
||||
private authorization: string;
|
||||
private authorization?: string;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@@ -36,15 +35,15 @@ export class RequestService implements IRequestService {
|
||||
|
||||
private configure(config: IHTTPConfiguration) {
|
||||
this.proxyUrl = config.http && config.http.proxy;
|
||||
this.strictSSL = config.http && config.http.proxyStrictSSL;
|
||||
this.strictSSL = !!(config.http && config.http.proxyStrictSSL);
|
||||
this.authorization = config.http && config.http.proxyAuthorization;
|
||||
}
|
||||
|
||||
request(options: IRequestOptions, requestFn: IRequestFunction = request): TPromise<IRequestContext> {
|
||||
request(options: IRequestOptions, token: CancellationToken, requestFn: IRequestFunction = request): Promise<IRequestContext> {
|
||||
this.logService.trace('RequestService#request', options.url);
|
||||
|
||||
const { proxyUrl, strictSSL } = this;
|
||||
const agentPromise = options.agent ? TPromise.wrap(options.agent) : TPromise.wrap(getProxyAgent(options.url, { proxyUrl, strictSSL }));
|
||||
const agentPromise = options.agent ? Promise.resolve(options.agent) : Promise.resolve(getProxyAgent(options.url || '', { proxyUrl, strictSSL }));
|
||||
|
||||
return agentPromise.then(agent => {
|
||||
options.agent = agent;
|
||||
@@ -54,7 +53,7 @@ export class RequestService implements IRequestService {
|
||||
options.headers = assign(options.headers || {}, { 'Proxy-Authorization': this.authorization });
|
||||
}
|
||||
|
||||
return requestFn(options);
|
||||
return requestFn(options, token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user