From 4cd093dbdf4cf1084a601286b3be5f1f0de0d350 Mon Sep 17 00:00:00 2001 From: Harry Yu Date: Mon, 1 Feb 2021 16:03:13 +0800 Subject: [PATCH 1/2] Fix Proxy --- Flow.Launcher.Infrastructure/Http/Http.cs | 2 ++ Flow.Launcher/App.xaml.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index 5af50bc6dca..9889767498e 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -34,6 +34,7 @@ static Http() client = new HttpClient(socketsHttpHandler, false); client.DefaultRequestHeaders.Add("User-Agent", UserAgent); + HttpClient.DefaultProxy = WebProxy; } private static HttpProxy proxy; @@ -45,6 +46,7 @@ public static HttpProxy Proxy { proxy = value; proxy.PropertyChanged += UpdateProxy; + UpdateProxy(ProxyProperty.Enabled); } } diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 06bb16e3be2..7c4c6a36716 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -61,6 +61,8 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => _settingsVM = new SettingWindowViewModel(_updater, _portable); _settings = _settingsVM.Settings; + Http.Proxy = _settings.Proxy; + _alphabet.Initialize(_settings); _stringMatcher = new StringMatcher(_alphabet); StringMatcher.Instance = _stringMatcher; @@ -85,8 +87,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => ThemeManager.Instance.Settings = _settings; ThemeManager.Instance.ChangeTheme(_settings.Theme); - Http.Proxy = _settings.Proxy; - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); RegisterExitEvents(); From 3453b178e28a7ae43c997205b789233ec56d38d2 Mon Sep 17 00:00:00 2001 From: Harry Yu Date: Mon, 1 Feb 2021 16:25:57 +0800 Subject: [PATCH 2/2] Remove socketsHttpHandler --- Flow.Launcher.Infrastructure/Http/Http.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index 9889767498e..de2e823590b 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -16,13 +16,7 @@ public static class Http { private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko"; - private static HttpClient client; - - private static SocketsHttpHandler socketsHttpHandler = new SocketsHttpHandler() - { - UseProxy = true, - Proxy = WebProxy - }; + private static HttpClient client = new HttpClient(); static Http() { @@ -32,7 +26,6 @@ static Http() | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; - client = new HttpClient(socketsHttpHandler, false); client.DefaultRequestHeaders.Add("User-Agent", UserAgent); HttpClient.DefaultProxy = WebProxy; }