From 21aa31f963deda7a7198b655cfe28db5be930004 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 9 May 2016 23:51:10 +0100 Subject: [PATCH] Fix proxy for github update --- Wox.Core/Updater.cs | 6 +++++- Wox.Infrastructure/Http/HttpRequest.cs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index 77550c2e27..0c142da102 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -16,10 +16,14 @@ namespace Wox.Core [Conditional("RELEASE")] public static async void UpdateApp() { + + var client = new WebClient {Proxy = HttpRequest.WebProxy(HttpProxy.Instance)}; + var downloader = new FileDownloader(client); + try { // todo 5/9 the return value of UpdateApp() is NULL, fucking useless! - using (var updater= await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github)) + using (var updater= await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, urlDownloader:downloader)) { await updater.UpdateApp(); } diff --git a/Wox.Infrastructure/Http/HttpRequest.cs b/Wox.Infrastructure/Http/HttpRequest.cs index 6dd7030afc..c1a95ec113 100644 --- a/Wox.Infrastructure/Http/HttpRequest.cs +++ b/Wox.Infrastructure/Http/HttpRequest.cs @@ -13,7 +13,7 @@ namespace Wox.Infrastructure.Http { public static class HttpRequest { - private static WebProxy GetWebProxy(IHttpProxy proxy) + public static WebProxy WebProxy(IHttpProxy proxy) { if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server)) { @@ -43,7 +43,7 @@ namespace Wox.Infrastructure.Http HttpWebRequest request = WebRequest.CreateHttp(url); request.Method = "GET"; request.Timeout = 10 * 1000; - request.Proxy = GetWebProxy(proxy); + request.Proxy = WebProxy(proxy); request.UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko"; HttpWebResponse response; try