mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-22 01:58:04 +00:00
* Update release.yml * Update ColorPickerUI.csproj * Update release.yml adding in .net6 sdk and moving stuff sooner * Update release.yml * Update release.yml * fixing test * Forcing vs17 and adding in .net 6 sdk * forcing pool * fixing issues in each pipeline * moving release .net up * fixing diff on agent version for nuget installer * Removing system.text.json.dll as included now * getting unit tests it looks like to work * updating everythign to .net 6 minus wxs for runtime * unit test still have * getting 6.0 stuff up and going. Terminal Unit tests have file max length issue .... * found i think the last .net 5 issue * looks like i wasn't aggressive enough with the 6.0 upgrade * Getting stuff .net 6 buildable again * tweaking with new stuff for installer * Update newly added merged projects to .net 6 * Fix HeatDirectory bug on VS 2022 * Settings still needs JSON dependency * Revert "getting 6.0 stuff up and going. Terminal Unit tests have file max length issue ...." This reverts commit b9cb4586dcaf693272b8bd895fc19783421262cc. * Update sln version * supress obsolete warning, since this is not a new development * Partially Revert "Getting stuff .net 6 buildable again" This reverts commit 42b4201c6bb36354fb9d7d7935403dcb5b45a17c. * supress another obsolete warning, since this is not a new development * Reduce the unit test project name to avoid MAX PATH in CI * Upgrade project's toolset in the main solution * Some TODOs to review HttpClient usage * Upgrade project toolsets from other solutions * Install .net 6 instead of .net 5 * Fix issue when disabling PowerToys Run on .net framework 6 * Update docs for Visual Studio 2022 * PR comments: manually upgrade missing VS 2019 references * Discard no discard values to solve compiler warnings Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JetBrains.Annotations;
|
|
using Wox.Infrastructure.UserSettings;
|
|
using Wox.Plugin.Logger;
|
|
|
|
namespace Wox.Infrastructure.Http
|
|
{
|
|
public static class HttpClient
|
|
{
|
|
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
|
|
|
public static HttpProxy Proxy { get; set; }
|
|
|
|
public static IWebProxy WebProxy()
|
|
{
|
|
if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server))
|
|
{
|
|
if (string.IsNullOrEmpty(Proxy.UserName) || string.IsNullOrEmpty(Proxy.Password))
|
|
{
|
|
var webProxy = new WebProxy(Proxy.Server, Proxy.Port);
|
|
return webProxy;
|
|
}
|
|
else
|
|
{
|
|
var webProxy = new WebProxy(Proxy.Server, Proxy.Port)
|
|
{
|
|
Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password),
|
|
};
|
|
return webProxy;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return WebRequest.GetSystemWebProxy();
|
|
}
|
|
}
|
|
|
|
public static void Download([NotNull] Uri url, [NotNull] string filePath)
|
|
{
|
|
if (url == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(url));
|
|
}
|
|
|
|
#pragma warning disable SYSLIB0014 // Type or member is obsolete
|
|
|
|
// TODO: Verify if it's dead code or replace with HttpClient
|
|
var client = new WebClient { Proxy = WebProxy() };
|
|
#pragma warning restore SYSLIB0014 // Type or member is obsolete
|
|
client.Headers.Add("user-agent", UserAgent);
|
|
client.DownloadFile(url.AbsoluteUri, filePath);
|
|
client.Dispose();
|
|
}
|
|
}
|
|
}
|