Skip to content

Commit 9ae9a17

Browse files
committed
fix: handled responses with null content
1 parent 2f77cac commit 9ae9a17

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)