In AnyUnix environments, setting a proxy is as easy as:
http_proxy=http://localhost:8080 dotnet run
Or
export http_proxy=http://localhost:8080
dotnet run
On Windows, I want the same capability:
$env:http_proxy="http://localhost:8080"
dotnet run
Unfortunately, that does not work. Here is the test code to explain:
[OuterLoop("Uses external server")]
[PlatformSpecific(TestPlatforms.AnyUnix)] // The default proxy is resolved via WinINet on Windows.
[Fact]
public async Task ProxySetViaEnvironmentVariable_DefaultProxyCredentialsUsed()
{
var cred = new NetworkCredential(Guid.NewGuid().ToString("N"), Guid.NewGuid().ToString("N"));
LoopbackServer.Options options =
new LoopbackServer.Options { IsProxy = true, Username = cred.UserName, Password = cred.Password };
await LoopbackServer.CreateServerAsync(async (proxyServer, proxyUri) =>
{
// HttpWebRequest/HttpClient will read a default proxy from the http_proxy environment variable. Ensure
// that when it does our default proxy credentials are used. To avoid messing up anything else in this
// process we run the test in another process.
Can you please add support for http_proxy environment variables on Windows too and then fall back to the WinINet? I don't want to change my system configuration when I just need to proxy a single app or a few dotnet runs.
Here is a related issue, but not the same:
In AnyUnix environments, setting a proxy is as easy as:
Or
export http_proxy=http://localhost:8080 dotnet runOn Windows, I want the same capability:
Unfortunately, that does not work. Here is the test code to explain:
Can you please add support for
http_proxyenvironment variables on Windows too and then fall back to the WinINet? I don't want to change my system configuration when I just need to proxy a single app or a fewdotnet runs.Here is a related issue, but not the same: