Browse Source

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)

github-services/pull/2554/head
Federico Maccaroni 3 years ago committed by GitHub
parent
commit
bebf23785d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/Core/Services/ApiService.cs

15
src/Core/Services/ApiService.cs

@ -1,5 +1,6 @@ @@ -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 @@ -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

Loading…
Cancel
Save