Skip to content

Update WebClient to HttpClient implementations for downloading (WIP) #6476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 4, 2023
Prev Previous commit
Next Next commit
A HttpClient vs Webclient implementation
  • Loading branch information
rgesteve committed Nov 29, 2022
commit f33004afbba4db2d1b6f9f99593731548c5c5544
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
using Microsoft.ML;
Expand Down Expand Up @@ -113,10 +115,18 @@ class OutputScores

private static string Download(string baseGitPath, string dataFile)
{
#if false
using (WebClient client = new WebClient())
{
client.DownloadFile(new Uri($"{baseGitPath}"), dataFile);
}
#else
var httpClient = new HttpClient();
using (var file = File.OpenWrite(dataFile))
{
httpClient.GetStreamAsync(baseGitPath).ContinueWith((Task<Stream> t) => t.Result.CopyToAsync(file));
}
#endif

return dataFile;
}
Expand Down