Merge pull request #320 from harrynull/fix_proxy

Fix Http Proxy
This commit is contained in:
taooceros 2021-02-01 16:51:47 +08:00 committed by GitHub
commit 16da1e20ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View file

@ -16,13 +16,7 @@ namespace Flow.Launcher.Infrastructure.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,8 +26,8 @@ namespace Flow.Launcher.Infrastructure.Http
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;
client = new HttpClient(socketsHttpHandler, false);
client.DefaultRequestHeaders.Add("User-Agent", UserAgent);
HttpClient.DefaultProxy = WebProxy;
}
private static HttpProxy proxy;
@ -45,6 +39,7 @@ namespace Flow.Launcher.Infrastructure.Http
{
proxy = value;
proxy.PropertyChanged += UpdateProxy;
UpdateProxy(ProxyProperty.Enabled);
}
}

View file

@ -61,6 +61,8 @@ namespace Flow.Launcher
_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 @@ namespace Flow.Launcher
ThemeManager.Instance.Settings = _settings;
ThemeManager.Instance.ChangeTheme(_settings.Theme);
Http.Proxy = _settings.Proxy;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
RegisterExitEvents();