Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
Improve network performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Dec 30, 2017
1 parent 45d2314 commit 7daaae3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions OsuHelper/Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ public DataService(ISettingsService settingsService, ICacheService cacheService)
_settingsService = settingsService;
_cacheService = cacheService;

// Connection limit
ServicePointManager.DefaultConnectionLimit = 9999;

// Client
_httpClient = new HttpClient();
var handler = new HttpClientHandler();
if (handler.SupportsAutomaticDecompression)
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
_httpClient = new HttpClient(handler, true);
_httpClient.DefaultRequestHeaders.Add("User-Agent", "osu!helper (github.com/Tyrrrz/OsuHelper)");

// Rate limiting
Expand Down Expand Up @@ -63,7 +69,7 @@ private async Task<HttpResponseMessage> InternalSendRequestAsync(HttpRequestMess
await MaintainRateLimitAsync(TimeSpan.FromMinutes(1.0 / 1200));

// Get response
var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);
var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

// Check status code
// We throw our own exception here because default one doesn't have status code
Expand Down

0 comments on commit 7daaae3

Please sign in to comment.