Skip to content

Commit 4302a51

Browse files
committed
Revert "Replace WebClient usage with HttpClient (dotnet#6388)"
This reverts commit 60db8e8.
1 parent 8ba0bce commit 4302a51

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

test/Microsoft.ML.AutoML.Tests/DatasetUtil.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using System.IO.Compression;
99
using System.Linq;
1010
using System.Net;
11-
using System.Net.Http;
12-
using System.Threading.Tasks;
1311
using Microsoft.ML.Data;
1412
using Microsoft.ML.TestFrameworkCommon;
1513

@@ -187,13 +185,13 @@ public static string DownloadImageSet(string imagesDownloadFolder)
187185
string fileName = "flower_photos_tiny_set_for_unit_tests.zip";
188186
string url = $"https://aka.ms/mlnet-resources/datasets/flower_photos_tiny_set_for_unit_test.zip";
189187

190-
Download(url, imagesDownloadFolder, fileName).Wait();
188+
Download(url, imagesDownloadFolder, fileName);
191189
UnZip(Path.Combine(imagesDownloadFolder, fileName), imagesDownloadFolder);
192190

193191
return Path.GetFileNameWithoutExtension(fileName);
194192
}
195193

196-
private static async Task Download(string url, string destDir, string destFileName)
194+
private static void Download(string url, string destDir, string destFileName)
197195
{
198196
if (destFileName == null)
199197
destFileName = Path.GetFileName(new Uri(url).AbsolutePath); ;
@@ -205,16 +203,7 @@ private static async Task Download(string url, string destDir, string destFileNa
205203
if (File.Exists(relativeFilePath))
206204
return;
207205

208-
using (var client = new HttpClient())
209-
{
210-
var response = await client.GetAsync(url).ConfigureAwait(false);
211-
var stream = await response.EnsureSuccessStatusCode().Content.ReadAsStreamAsync().ConfigureAwait(false);
212-
var fileInfo = new FileInfo(relativeFilePath);
213-
using (var fileStream = fileInfo.OpenWrite())
214-
{
215-
await stream.CopyToAsync(fileStream).ConfigureAwait(false);
216-
}
217-
}
206+
new WebClient().DownloadFile(url, relativeFilePath);
218207
return;
219208
}
220209

0 commit comments

Comments
 (0)