Skip to content

Commit

Permalink
fix(abstractions): set http status code for response if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
gingters committed Mar 19, 2024
1 parent 3797392 commit b29c6fc
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ public static T CreateResponse<T>(this IClientRequest request, HttpStatusCode? h
HttpHeaders = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase),
};

if (httpStatusCode is not null)
{
response.HttpStatusCode = httpStatusCode.Value;
}

if (httpStatusCode == null || (int)httpStatusCode.GetValueOrDefault(HttpStatusCode.Continue) < 400)
return response;

response.OriginalBodySize = 0;
response.BodySize = 0;
response.HttpStatusCode = httpStatusCode.Value;
response.RequestFailed = true;

return response;
Expand Down

0 comments on commit b29c6fc

Please sign in to comment.