diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 90fd0af4d3..c0398d501b 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -18,7 +18,6 @@ using PowerLauncher.Plugin; using PowerLauncher.ViewModel; using Wox; using Wox.Infrastructure; -using Wox.Infrastructure.Http; using Wox.Infrastructure.Image; using Wox.Infrastructure.UserSettings; using Wox.Plugin; @@ -129,9 +128,6 @@ namespace PowerLauncher Current.MainWindow = _mainWindow; Current.MainWindow.Title = Constant.ExeFileName; - // main windows needs initialized before theme change because of blur settings - HttpClient.Proxy = _settings.Proxy; - RegisterExitEvents(); _settingsReader.ReadSettingsOnChange(); diff --git a/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs b/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs deleted file mode 100644 index 8c37db5e25..0000000000 --- a/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs +++ /dev/null @@ -1,86 +0,0 @@ -// 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; - -namespace PowerLauncher.Helper -{ - public class DataWebRequestFactory : IWebRequestCreate - { - private class DataWebRequest : WebRequest - { - private readonly Uri _uri; - -#pragma warning disable SYSLIB0014 // Type or member is obsolete - - // TODO: Verify if it's dead code or replace with HttpClient - public DataWebRequest(Uri uri) - { - _uri = uri; - } -#pragma warning restore SYSLIB0014 // Type or member is obsolete - - public override WebResponse GetResponse() - { - return new DataWebResponse(_uri); - } - } - - private class DataWebResponse : WebResponse - { - private readonly string _contentType; - private readonly byte[] _data; - - public DataWebResponse(Uri uri) - { - string uriString = uri.AbsoluteUri; - - // Using Ordinal since this is internal and used with a symbol - int commaIndex = uriString.IndexOf(',', StringComparison.Ordinal); - var headers = uriString.Substring(0, commaIndex).Split(';'); - _contentType = headers[0]; - string dataString = uriString.Substring(commaIndex + 1); - _data = Convert.FromBase64String(dataString); - } - - public override string ContentType - { - get - { - return _contentType; - } - - set - { - throw new NotSupportedException(); - } - } - - public override long ContentLength - { - get - { - return _data.Length; - } - - set - { - throw new NotSupportedException(); - } - } - - public override Stream GetResponseStream() - { - return new MemoryStream(_data); - } - } - - public WebRequest Create(Uri uri) - { - return new DataWebRequest(uri); - } - } -} diff --git a/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs b/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs index 8c6940973c..53dad925fc 100644 --- a/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs +++ b/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs @@ -5,19 +5,15 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; -using System.Reflection; using System.Windows; using Common.UI; using ManagedCommon; using Microsoft.Toolkit.Uwp.Notifications; -using PowerLauncher.Helper; using PowerLauncher.Plugin; using PowerLauncher.ViewModel; using Windows.UI.Notifications; using Wox.Infrastructure.Image; using Wox.Plugin; -using Wox.Plugin.Logger; namespace Wox { @@ -36,7 +32,6 @@ namespace Wox _mainVM = mainVM ?? throw new ArgumentNullException(nameof(mainVM)); _themeManager = themeManager ?? throw new ArgumentNullException(nameof(themeManager)); _themeManager.ThemeChanged += OnThemeChanged; - WebRequest.RegisterPrefix("data", new DataWebRequestFactory()); ToastNotificationManagerCompat.OnActivated += args => { diff --git a/src/modules/launcher/Wox.Infrastructure/Http/HttpClient.cs b/src/modules/launcher/Wox.Infrastructure/Http/HttpClient.cs deleted file mode 100644 index 0f81630159..0000000000 --- a/src/modules/launcher/Wox.Infrastructure/Http/HttpClient.cs +++ /dev/null @@ -1,65 +0,0 @@ -// 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(); - } - } -}