Skip to content

Commit 54874c2

Browse files
authored
Merge pull request #22 from FrApp42/dev/main
Fix: Handled responses with null content
2 parents 22aa4cd + 9ae9a17 commit 54874c2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Web/API/Request.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,19 @@ private async Task<Result<T>> Process<T>(HttpRequestMessage request)
391391
response = await _httpClient.SendAsync(request);
392392
result.StatusCode = (int)response.StatusCode;
393393

394+
if (
395+
response.Content == null ||
396+
string.IsNullOrEmpty(await response.Content.ReadAsStringAsync())
397+
)
398+
{
399+
result.Value = default;
400+
401+
return result;
402+
}
403+
394404
if (response.IsSuccessStatusCode)
395405
{
396-
string MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower();
406+
string? MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower();
397407
string ContentResponse = await response.Content?.ReadAsStringAsync();
398408

399409
switch (true)

0 commit comments

Comments
 (0)