Skip to content

Commit

Permalink
globally limit the maximum number of connections per server and optim…
Browse files Browse the repository at this point in the history
…ize streaming download speed

Signed-off-by: OsakaRuma <[email protected]>
  • Loading branch information
iamscottxu committed Aug 25, 2024
1 parent daa4bbd commit f33702f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Starward/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private static void BuildServiceProvider()
{
//See: https://learn.microsoft.com/zh-cn/dotnet/fundamentals/runtime-libraries/system-net-http-httpclienthandler
//See: https://learn.microsoft.com/zh-cn/dotnet/api/system.net.http.socketshttphandler?view=net-8.0
var client = new HttpClient(new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.All }) { DefaultRequestVersion = HttpVersion.Version20 };
var client = new HttpClient(new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.All, MaxConnectionsPerServer = 5 }) { DefaultRequestVersion = HttpVersion.Version20 };
client.DefaultRequestHeaders.Add("User-Agent", $"Starward/{AppVersion}");
return client;
});
Expand Down
3 changes: 2 additions & 1 deletion src/Starward/Services/Download/InstallGameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,8 @@ protected async Task StreamDownloadItemAsync(InstallGameItem item, CancellationT
EnableFullStreamDownload = true,
CheckDateTimeVerifyingExistingFile = checkDateTimeVerifying,
CheckCrcVerifyingExistingFile = checkCrcVerifying,
Progress = progress.Progress,
DownloadThreadCount = 20,
Progress = progress.Progress
};

var downloadingStarted = false;
Expand Down

0 comments on commit f33702f

Please sign in to comment.