From 11b6946e00407b79e13e48ce677226e57bf01b4d Mon Sep 17 00:00:00 2001 From: Tobias Tschinkowitz Date: Wed, 27 Jul 2016 15:25:16 +0200 Subject: [PATCH] Providing User Agent for Http.Download method (#874) --- Wox.Infrastructure/Http/Http.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Wox.Infrastructure/Http/Http.cs b/Wox.Infrastructure/Http/Http.cs index bd55a468dc..2cff5fc6fe 100644 --- a/Wox.Infrastructure/Http/Http.cs +++ b/Wox.Infrastructure/Http/Http.cs @@ -9,6 +9,8 @@ namespace Wox.Infrastructure.Http { public static class Http { + private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko"; + public static HttpProxy Proxy { private get; set; } public static IWebProxy WebProxy() { @@ -38,6 +40,7 @@ namespace Wox.Infrastructure.Http public static void Download([NotNull] string url, [NotNull] string filePath) { var client = new WebClient { Proxy = WebProxy() }; + client.Headers.Add("user-agent", UserAgent); client.DownloadFile(url, filePath); } @@ -49,7 +52,7 @@ namespace Wox.Infrastructure.Http request.Method = "GET"; request.Timeout = 10 * 1000; request.Proxy = WebProxy(); - request.UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko"; + request.UserAgent = UserAgent; var response = await request.GetResponseAsync() as HttpWebResponse; if (response != null) {