BREAKING CHANGE (behavior): Modify caching to only attempt to update the response cache if a 2xx response code is received from GitHub (#2877)

Only update response cache for successful api responses

Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com>
This commit is contained in:
David Rant
2024-03-12 19:36:11 +00:00
committed by GitHub
parent 1dc9c5e78c
commit 92ff70b5ed
3 changed files with 121 additions and 21 deletions
+26
View File
@@ -0,0 +1,26 @@
using System.Threading;
using System.Threading.Tasks;
using Octokit.Internal;
namespace Octokit
{
public static class HttpExtensions
{
public static Task<IResponse> Send(this IHttpClient httpClient, IRequest request)
{
Ensure.ArgumentNotNull(httpClient, nameof(httpClient));
Ensure.ArgumentNotNull(request, nameof(request));
return httpClient.Send(request, CancellationToken.None);
}
/// <summary>
/// Gets a value that indicates whether the HTTP response was successful.
/// </summary>
public static bool IsSuccessStatusCode(this IResponse response)
{
Ensure.ArgumentNotNull(response, nameof(response));
return (int) response.StatusCode >= 200 && (int) response.StatusCode <= 299;
}
}
}