diff --git a/OpenDirectoryDownloader/OpenDirectoryIndexer.cs b/OpenDirectoryDownloader/OpenDirectoryIndexer.cs index 1e327dea..eb059bb2 100644 --- a/OpenDirectoryDownloader/OpenDirectoryIndexer.cs +++ b/OpenDirectoryDownloader/OpenDirectoryIndexer.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Text; @@ -116,7 +117,8 @@ public OpenDirectoryIndexer(OpenDirectoryIndexerSettings openDirectoryIndexerSet HttpClientHandler = new HttpClientHandler { - ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true + ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true, + AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli }; HttpClient = new HttpClient(HttpClientHandler) @@ -124,6 +126,8 @@ public OpenDirectoryIndexer(OpenDirectoryIndexerSettings openDirectoryIndexerSet Timeout = TimeSpan.FromSeconds(OpenDirectoryIndexerSettings.Timeout) }; + HttpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip, deflate, br"); + if (!string.IsNullOrWhiteSpace(OpenDirectoryIndexerSettings.Username) && !string.IsNullOrWhiteSpace(OpenDirectoryIndexerSettings.Password)) { HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{OpenDirectoryIndexerSettings.Username}:{OpenDirectoryIndexerSettings.Password}")));