Skip to content

Commit

Permalink
Download: fix getFilefromNet for slow downloads
Browse files Browse the repository at this point in the history
This returns a response as soon as the header comes in, which makes the
progress bar/ETA work as intended. Previously, the entire file would be
downloaded before the response could even be checked, causing timeouts
for large files or slow connections.
  • Loading branch information
robertlong13 authored and meee1 committed Dec 26, 2024
1 parent d228b63 commit 5983ab4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ExtLibs/Utilities/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static async Task<bool> getFilefromNetAsync(string url, string saveto, Ac

RequestModification?.Invoke(url, request);

using (var response = await client.SendAsync(request).ConfigureAwait(false))
using (var response = await client.SendAsync(request, completionOption: HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false))
{
lock (log)
log.Info(url + " " +(response).StatusCode.ToString());
Expand Down Expand Up @@ -458,7 +458,7 @@ public static bool getFilefromNet(string url, string saveto, Action<int, string>
client.Timeout = TimeSpan.FromSeconds(30);

// Get the response.
var response = client.GetAsync(url).Result;
var response = client.GetAsync(url, completionOption: HttpCompletionOption.ResponseHeadersRead).Result;
// Display the status.
lock (log)
log.Info(response.ReasonPhrase);
Expand Down

0 comments on commit 5983ab4

Please sign in to comment.