mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
fix profile import/export in web (#171753)
- move it to configuration-editing extension
This commit is contained in:
committed by
GitHub
parent
df24bef783
commit
5b02e68e42
29
extensions/configuration-editing/src/node/net.ts
Normal file
29
extensions/configuration-editing/src/node/net.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Agent, globalAgent } from 'https';
|
||||
import { URL } from 'url';
|
||||
import { httpsOverHttp } from 'tunnel';
|
||||
import { window } from 'vscode';
|
||||
|
||||
export const agent = getAgent();
|
||||
|
||||
/**
|
||||
* Return an https agent for the given proxy URL, or return the
|
||||
* global https agent if the URL was empty or invalid.
|
||||
*/
|
||||
function getAgent(url: string | undefined = process.env.HTTPS_PROXY): Agent {
|
||||
if (!url) {
|
||||
return globalAgent;
|
||||
}
|
||||
try {
|
||||
const { hostname, port, username, password } = new URL(url);
|
||||
const auth = username && password && `${username}:${password}`;
|
||||
return httpsOverHttp({ proxy: { host: hostname, port, proxyAuth: auth } });
|
||||
} catch (e) {
|
||||
window.showErrorMessage(`HTTPS_PROXY environment variable ignored: ${e.message}`);
|
||||
return globalAgent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user