| 161 | } |
| 162 | |
| 163 | static async Task<string> DownloadString(string url) |
| 164 | { |
| 165 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
| 166 | request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; |
| 167 | request.UserAgent = USER_AGENT; |
| 168 | |
| 169 | using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync()) |
| 170 | using (Stream stream = response.GetResponseStream()) |
| 171 | using (StreamReader reader = new StreamReader(stream)) |
| 172 | { |
| 173 | return await reader.ReadToEndAsync(); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | static async Task DownloadFile(string url, string path, Action<long, long, int> onProgress) |
| 178 | { |