-
Notifications
You must be signed in to change notification settings - Fork 30.2k
/
Copy pathrequestService.ts
38 lines (32 loc) · 1.64 KB
/
requestService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken } from 'vs/base/common/cancellation';
import { request } from 'vs/base/parts/request/browser/request';
import { IRequestContext, IRequestOptions } from 'vs/base/parts/request/common/request';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILoggerService } from 'vs/platform/log/common/log';
import { AbstractRequestService, IRequestService } from 'vs/platform/request/common/request';
/**
* This service exposes the `request` API, while using the global
* or configured proxy settings.
*/
export class RequestService extends AbstractRequestService implements IRequestService {
declare readonly _serviceBrand: undefined;
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
@ILoggerService loggerService: ILoggerService
) {
super(loggerService);
}
async request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
if (!options.proxyAuthorization) {
options.proxyAuthorization = this.configurationService.getValue<string>('http.proxyAuthorization');
}
return this.logAndRequest('browser', options, () => request(options, token));
}
async resolveProxy(url: string): Promise<string | undefined> {
return undefined; // not implemented in the web
}
}