Skip to content

Commit

Permalink
Merge pull request #22 from FrApp42/dev/main
Browse files Browse the repository at this point in the history
Fix: Handled responses with null content
  • Loading branch information
sikelio authored Oct 7, 2024
2 parents 22aa4cd + 9ae9a17 commit 54874c2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Web/API/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,19 @@ private async Task<Result<T>> Process<T>(HttpRequestMessage request)
response = await _httpClient.SendAsync(request);
result.StatusCode = (int)response.StatusCode;

if (
response.Content == null ||
string.IsNullOrEmpty(await response.Content.ReadAsStringAsync())
)
{
result.Value = default;

return result;
}

if (response.IsSuccessStatusCode)
{
string MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower();
string? MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower();

Check warning on line 406 in Web/API/Request.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
string ContentResponse = await response.Content?.ReadAsStringAsync();

Check warning on line 407 in Web/API/Request.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

switch (true)
Expand Down

0 comments on commit 54874c2

Please sign in to comment.