Skip to content

Commit

Permalink
Expose EnsureSuccessStatusCode on response
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocontrini committed Oct 26, 2023
1 parent 6098e03 commit 5f1c96b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions PlainHttp/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ public async Task ReadBody()
}
}

public void EnsureSuccessStatusCode()
{
try
{
this.Message.EnsureSuccessStatusCode();
}
catch (System.Net.Http.HttpRequestException ex)
{
throw new HttpRequestException(this.Request, ex);
}
}

public void Dispose()
{
this.Message.Dispose();
Expand Down
1 change: 1 addition & 0 deletions PlainHttp/IHttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface IHttpResponse

string? GetSingleHeader(string name);
Task ReadBody();
void EnsureSuccessStatusCode();
}

0 comments on commit 5f1c96b

Please sign in to comment.