Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use affectsConfiguration #169818

Merged
merged 1 commit into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/vs/platform/request/common/request.ts
Expand Up @@ -62,14 +62,6 @@ export async function asJson<T = {}>(context: IRequestContext): Promise<T | null
}


export interface IHTTPConfiguration {
http?: {
proxy?: string;
proxyStrictSSL?: boolean;
proxyAuthorization?: string;
};
}

export function updateProxyConfigurationsScope(scope: ConfigurationScope): void {
registerProxyConfigurations(scope);
}
Expand Down
25 changes: 18 additions & 7 deletions src/vs/platform/request/node/requestService.ts
Expand Up @@ -18,10 +18,16 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import { getResolvedShellEnv } from 'vs/platform/shell/node/shellEnv';
import { ILogService } from 'vs/platform/log/common/log';
import { IHTTPConfiguration, IRequestService } from 'vs/platform/request/common/request';
import { IRequestService } from 'vs/platform/request/common/request';
import { Agent, getProxyAgent } from 'vs/platform/request/node/proxy';
import { createGunzip } from 'zlib';

interface IHTTPConfiguration {
proxy?: string;
proxyStrictSSL?: boolean;
proxyAuthorization?: string;
}

export interface IRawRequestFunction {
(options: http.RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
}
Expand Down Expand Up @@ -52,14 +58,19 @@ export class RequestService extends Disposable implements IRequestService {
@ILogService private readonly logService: ILogService
) {
super();
this.configure(configurationService.getValue<IHTTPConfiguration>());
this._register(configurationService.onDidChangeConfiguration(() => this.configure(configurationService.getValue()), this));
this.configure();
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('http')) {
this.configure();
}
}));
}

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;
private configure() {
const config = this.configurationService.getValue<IHTTPConfiguration | undefined>('http');
this.proxyUrl = config?.proxy;
this.strictSSL = !!config?.proxyStrictSSL;
this.authorization = config?.proxyAuthorization;
}

async request(options: NodeRequestOptions, token: CancellationToken): Promise<IRequestContext> {
Expand Down
Expand Up @@ -66,7 +66,11 @@ class MarkersFileDecorations implements IWorkbenchContribution {
) {
//
this._disposables = [
this._configurationService.onDidChangeConfiguration(this._updateEnablement, this),
this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('problems')) {
this._updateEnablement();
}
}),
];
this._updateEnablement();
}
Expand Down