Skip to content

Commit

Permalink
replace WebClient with HttpClient in signature verification test code
Browse files Browse the repository at this point in the history
  • Loading branch information
striezel committed Oct 5, 2024
1 parent 834881d commit 20bca60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions updater-test/utility/Verificator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Net;
using System.Net.Http;

namespace updater_test.utility
{
Expand Down Expand Up @@ -50,17 +50,21 @@ public class Verificator_Tests
private static string Download(string url)
{
string localFile = Path.Combine(Path.GetTempPath(), "test_original.msi");
using (var wc = new WebClient())
using (var client = new HttpClient())
{
try
{
wc.DownloadFile(url, localFile);
var stream_task = client.GetStreamAsync(url);
stream_task.Wait();
using var stream = stream_task.Result;
using var file = new FileStream(localFile, FileMode.CreateNew);
stream.CopyTo(file);
}
catch (Exception ex)
{
Console.WriteLine("An error occurred while downloading the file "
+ url + ": " + ex.Message);
wc.Dispose();
client.Dispose();
return null;
}
} // using
Expand Down

0 comments on commit 20bca60

Please sign in to comment.