Skip to content

Commit 16da1e2

Browse files
authored
Merge pull request #320 from harrynull/fix_proxy
Fix Http Proxy
2 parents d509b11 + 3453b17 commit 16da1e2

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ public static class Http
1616
{
1717
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
1818

19-
private static HttpClient client;
20-
21-
private static SocketsHttpHandler socketsHttpHandler = new SocketsHttpHandler()
22-
{
23-
UseProxy = true,
24-
Proxy = WebProxy
25-
};
19+
private static HttpClient client = new HttpClient();
2620

2721
static Http()
2822
{
@@ -32,8 +26,8 @@ static Http()
3226
| SecurityProtocolType.Tls11
3327
| SecurityProtocolType.Tls12;
3428

35-
client = new HttpClient(socketsHttpHandler, false);
3629
client.DefaultRequestHeaders.Add("User-Agent", UserAgent);
30+
HttpClient.DefaultProxy = WebProxy;
3731
}
3832

3933
private static HttpProxy proxy;
@@ -45,6 +39,7 @@ public static HttpProxy Proxy
4539
{
4640
proxy = value;
4741
proxy.PropertyChanged += UpdateProxy;
42+
UpdateProxy(ProxyProperty.Enabled);
4843
}
4944
}
5045

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
6161
_settingsVM = new SettingWindowViewModel(_updater, _portable);
6262
_settings = _settingsVM.Settings;
6363

64+
Http.Proxy = _settings.Proxy;
65+
6466
_alphabet.Initialize(_settings);
6567
_stringMatcher = new StringMatcher(_alphabet);
6668
StringMatcher.Instance = _stringMatcher;
@@ -85,8 +87,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
8587
ThemeManager.Instance.Settings = _settings;
8688
ThemeManager.Instance.ChangeTheme(_settings.Theme);
8789

88-
Http.Proxy = _settings.Proxy;
89-
9090
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
9191

9292
RegisterExitEvents();

0 commit comments

Comments
 (0)