PM-2232 Fix api response not being read as string because the content was not being considered json when it was indeed. Now Netacea messages are shown on the UI. (#2541)

This commit is contained in:
Federico Maccaroni 2023-06-01 10:35:35 +03:00 committed by GitHub
parent e78833cbcb
commit bebf23785d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
@ -975,7 +976,19 @@ namespace Bit.Core.Services
private bool IsJsonResponse(HttpResponseMessage response)
{
return (response.Content?.Headers?.ContentType?.MediaType ?? string.Empty) == "application/json";
if (response.Content?.Headers is null)
{
return false;
}
if (response.Content.Headers.ContentType?.MediaType == "application/json")
{
return true;
}
return response.Content.Headers.TryGetValues("Content-Type", out var vals)
&&
vals?.Any(v => v.Contains("application/json")) is true;
}
#endregion