From cac570fdb99d8f0dd2b85277296e0d501a1cc599 Mon Sep 17 00:00:00 2001 From: feelinLit Date: Sat, 19 Oct 2024 13:09:01 +0300 Subject: [PATCH] fix(HEAD request): throw exception when response is not 200 and 204 --- src/BirdMessenger/HttpClientExtension.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/BirdMessenger/HttpClientExtension.cs b/src/BirdMessenger/HttpClientExtension.cs index 9a75c33..49b4f61 100644 --- a/src/BirdMessenger/HttpClientExtension.cs +++ b/src/BirdMessenger/HttpClientExtension.cs @@ -139,10 +139,9 @@ public static async Task TusHeadAsync(this HttpClient httpClien PreSendRequestEvent preSendRequestEvent = new PreSendRequestEvent(reqOption, httpReqMsg); await reqOption.OnPreSendRequestAsync(preSendRequestEvent); } - var response = await httpClient.SendAsync(httpReqMsg, ct); - if (response.StatusCode == HttpStatusCode.NotFound || - response.StatusCode == HttpStatusCode.Gone || - response.StatusCode == HttpStatusCode.Forbidden) + var response = await httpClient.SendAsync(httpReqMsg, ct); + if (response.StatusCode != HttpStatusCode.OK && + response.StatusCode != HttpStatusCode.NoContent) { throw new TusException($" head response statusCode is{response.StatusCode.ToString()} ",httpReqMsg,response); }