Skip to content

Commit

Permalink
Enable for remote (#228697)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Nov 6, 2024
1 parent 76c27ee commit d35171f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/request/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function registerProxyConfigurations(scope: ConfigurationScope): void {
'http.fetchAdditionalSupport': {
type: 'boolean',
default: true,
description: localize('fetchAdditionalSupport', "Controls whether Node.js' fetch implementation should be extended with additional support."),
markdownDescription: localize('fetchAdditionalSupport', "Controls whether Node.js' fetch implementation should be extended with additional support. Currently proxy support ({0}) and system certificates ({1}) are added when the corresponding settings are enabled.", '`#http.proxySupport#`', '`#http.systemCertificates#`'),
restricted: true
}
}
Expand Down
19 changes: 11 additions & 8 deletions src/vs/workbench/api/node/proxyResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ const unsafeHeaders = [
];

function patchGlobalFetch(configProvider: ExtHostConfigProvider, mainThreadTelemetry: MainThreadTelemetryShape, initData: IExtensionHostInitData, resolveProxyURL: (url: string) => Promise<string | undefined>, lookupProxyAuthorization: LookupProxyAuthorization, loadAdditionalCertificates: () => Promise<string[]>, disposables: DisposableStore) {
if (!initData.remote.isRemote && !(globalThis as any).__vscodeOriginalFetch) {
if (!(globalThis as any).__vscodeOriginalFetch) {
const originalFetch = globalThis.fetch;
(globalThis as any).__vscodeOriginalFetch = originalFetch;
const patchedFetch = patchFetch(originalFetch, configProvider, resolveProxyURL, lookupProxyAuthorization, loadAdditionalCertificates);
(globalThis as any).__vscodePatchedFetch = patchedFetch;
let useElectronFetch = configProvider.getConfiguration('http').get<boolean>('electronFetch', useElectronFetchDefault);
disposables.add(configProvider.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('http.electronFetch')) {
useElectronFetch = configProvider.getConfiguration('http').get<boolean>('electronFetch', useElectronFetchDefault);
}
}));
const electron = require('electron');
let useElectronFetch = false;
if (!initData.remote.isRemote) {
useElectronFetch = configProvider.getConfiguration('http').get<boolean>('electronFetch', useElectronFetchDefault);
disposables.add(configProvider.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('http.electronFetch')) {
useElectronFetch = configProvider.getConfiguration('http').get<boolean>('electronFetch', useElectronFetchDefault);
}
}));
}
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
globalThis.fetch = async function fetch(input: string | URL | Request, init?: RequestInit) {
function getRequestProperty(name: keyof Request & keyof RequestInit) {
Expand Down Expand Up @@ -160,6 +162,7 @@ function patchGlobalFetch(configProvider: ExtHostConfigProvider, mainThreadTelem
}
// Support for URL: https://github.com/electron/electron/issues/43712
const electronInput = input instanceof URL ? input.toString() : input;
const electron = require('electron');
const response = await electron.net.fetch(electronInput, init);
monitorResponseProperties(mainThreadTelemetry, response, urlString);
return response;
Expand Down

0 comments on commit d35171f

Please sign in to comment.