I have a Web Api that send me the responses compress with brotli and I have a console app that use a HttpClient by request the data to my WebApi. I need decompress the data send by my WebApi.
For .Net Core 2.2
Startup.cs
//Compresión de respuestas del servidor
services.Configure<BrotliCompressionProviderOptions>(opciones =>
opciones.Level = CompressionLevel.Optimal
);
services.AddResponseCompression(opciones =>
{
opciones.EnableForHttps = true;
opciones.Providers.Add<BrotliCompressionProvider>();
});
ConseleApp
using (var client = new HttpClient(handler)){
client.BaseAddress = new Uri(BASE_URL);
client.Timeout = new TimeSpan(0, 0, TIMEOUT_SECONDS);
HttpRequestHeaders headers = client.DefaultRequestHeaders;
headers.Add("X-User", Environment.UserName);
headers.Add("Accept-Encoding", "br"); //gzip
HttpResponseMessage response = null;
response = await client.GetAsync($"{requestUrl}");
if (response.IsSuccessStatusCode)
{
string strResult = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(strResult);
}
}
The strResult is not JSON. . .