Skip to content

Commit a002528

Browse files
authored
fix(http): enable automatic decompression on OmbiClient (#5410)
1 parent fb84346 commit a002528

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/Ombi.DependencyInjection/IocExtensions.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Net;
23
using System.Security.Principal;
34
using Microsoft.AspNetCore.Http;
45
using Microsoft.Extensions.DependencyInjection;
@@ -138,7 +139,16 @@ public static void RegisterHttp(this IServiceCollection services)
138139
client.DefaultRequestHeaders.Add("User-Agent", $"Ombi/{runtimeVersion} (https://ombi.io/)");
139140
}).ConfigurePrimaryHttpMessageHandler(() =>
140141
{
141-
var httpClientHandler = new HttpClientHandler();
142+
var httpClientHandler = new HttpClientHandler
143+
{
144+
// Some upstream APIs (notably TheMovieDb behind its CDN) may return
145+
// gzip/brotli-encoded responses even when no Accept-Encoding header is
146+
// sent. Without automatic decompression the raw compressed bytes are
147+
// handed to ReadAsStringAsync, producing UTF-8 replacement characters
148+
// (U+FFFD) and a Newtonsoft.Json "Unexpected character ... line 0,
149+
// position 0" failure (intermittent, often seen under Docker on Linux).
150+
AutomaticDecompression = DecompressionMethods.All,
151+
};
142152
httpClientHandler.ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true;
143153

144154
return httpClientHandler;

0 commit comments

Comments
 (0)