Skip to content

Commit

Permalink
Merge pull request #60 from feelinLit/fix/head-incorrect-status-handling
Browse files Browse the repository at this point in the history
fix(HEAD request): throw exception if response is not 200 and not 204
  • Loading branch information
bluetianx authored Oct 20, 2024
2 parents a091628 + cac570f commit c6ae4e4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/BirdMessenger/HttpClientExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ public static async Task<TusHeadResponse> 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);
}
Expand Down

0 comments on commit c6ae4e4

Please sign in to comment.