Skip to content

Conversation

@kampute
Copy link
Owner

@kampute kampute commented Dec 21, 2025

This pull request introduces several improvements and updates across the codebase, focusing primarily on enhancing HTTP error handling and updating dependencies to support .NET 10.0 and newer library versions. The most significant changes are the introduction of a new abstract base class for retryable HTTP error handling and a refactor of the HttpError429Handler to leverage this abstraction. Additionally, there are updates to project metadata and dependency versions, as well as workflow configuration changes.

HTTP Error Handling Improvements

  • Added a new abstract base class RetryableHttpErrorHandler in src/Kampute.HttpClient/ErrorHandlers/Abstracts/RetryableHttpErrorHandler.cs, which provides a reusable mechanism for handling transient HTTP errors with customizable backoff and retry strategies. This class is designed to be extended for specific error codes and centralizes retry logic.
  • Refactored HttpError429Handler in src/Kampute.HttpClient/ErrorHandlers/HttpError429Handler.cs to inherit from RetryableHttpErrorHandler, simplifying its implementation and aligning its retry logic with the new abstraction. The handler now uses a rate limit reset header for retry timing and disables retries if not present.
  • Added a documentation-only class NamespaceDoc to src/Kampute.HttpClient/ErrorHandlers/Abstracts/NamespaceDoc.cs to clarify the purpose of the error handler abstracts namespace.

Dependency and SDK Updates

  • Updated the GitHub Actions workflow in .github/workflows/main.yml to use .NET SDK 10.0.x instead of 8.0.x, ensuring compatibility with the latest .NET features.
  • Changed package references in project files (Kampute.HttpClient.Json.csproj, Kampute.HttpClient.NewtonsoftJson.csproj) to use wildcard versions (10.* for System.Text.Json and 13.* for Newtonsoft.Json), allowing for automatic updates to the latest minor and patch releases. [1] [2]

Project Metadata Updates

  • Bumped package versions from 2.4.0 to 2.5.0 and updated copyright years to 2025 in Kampute.HttpClient.DataContract.csproj, Kampute.HttpClient.NewtonsoftJson.csproj, and Kampute.HttpClient.Xml.csproj to reflect the new release. [1] [2] [3]

Workflow Configuration

  • Set keep_files: false in the GitHub Pages deployment step to ensure old files are removed during publish, preventing stale content. (.github/workflows/main.yml)

- Introduce RetryableHttpErrorHandler abstract base for transient error handling
- Add TransientHttpErrorHandler for multiple status codes
- Refactor HttpError429Handler and HttpError503Handler to use new base class
- Update project versions to 2.5.0 and copyright to 2025
- Relax Newtonsoft.Json and System.Text.Json package versions
- Improve HttpRequestMessageCloneManager disposal logic
- Minor variable renaming and add namespace documentation stub
- Target .NET 10.0 in all test projects; update NUnit3TestAdapter to 6.0.1
- Replace deprecated Assert.Multiple with Assert.EnterMultipleScope
- Use C# 12 collection expressions in assertions
- Add TransientHttpErrorHandlerTests for coverage of transient error handling and backoff logic
- Introduce TestStream helper for seekable/non-seekable stream tests
- Refactor tests to use TestStream for content reusability checks
- Add tests for compressed content retry scenarios (gzip/deflate)
- Minor assertion improvements for clarity and consistency
- Modernize and improve maintainability of the test suite
Switched GitHub Actions workflow to use .NET SDK 10.0.x.
Set keep_files: false in gh-pages deploy to remove old files.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces version 2.5.0 of Kampute.HttpClient with enhancements to HTTP error handling architecture, .NET 10.0 support, and dependency updates. The main focus is on introducing a reusable abstraction for retryable HTTP error handlers and modernizing test infrastructure.

Key changes include:

  • Introduction of RetryableHttpErrorHandler abstract base class to centralize retry logic for transient HTTP errors, with refactored HttpError429Handler and HttpError503Handler implementations
  • New TransientHttpErrorHandler for handling multiple transient error status codes (408, 502, 503, 504, 507, 509) with a single configurable handler
  • Upgrade to .NET 10.0 SDK and target framework across all test projects, with NUnit 6.0.1 test adapter and wildcard package version specifications

Reviewed changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Kampute.HttpClient/ErrorHandlers/Abstracts/RetryableHttpErrorHandler.cs New abstract base class providing reusable retry logic with customizable backoff strategies for transient HTTP errors
src/Kampute.HttpClient/ErrorHandlers/TransientHttpErrorHandler.cs New handler supporting multiple configurable transient error status codes (408, 502, 503, 504, 507, 509)
src/Kampute.HttpClient/ErrorHandlers/HttpError429Handler.cs Refactored to inherit from RetryableHttpErrorHandler, now uses rate limit reset header with no-retry default
src/Kampute.HttpClient/ErrorHandlers/HttpError503Handler.cs Simplified by inheriting from RetryableHttpErrorHandler, leveraging base class retry logic
src/Kampute.HttpClient/ErrorHandlers/Abstracts/NamespaceDoc.cs Documentation-only class describing the abstracts namespace purpose
src/Kampute.HttpClient/HttpRestClient.cs Minor variable renaming for consistency (context → ctx)
src/Kampute.HttpClient/HttpRequestMessageCloneManager.cs Refactored DisposeNonOriginalRequest to use early return pattern for improved readability
src/Kampute.HttpClient/Kampute.HttpClient.csproj Version bump to 2.5.0 and copyright year update to 2025
src/Kampute.HttpClient./Kampute.HttpClient..csproj Version bumps to 2.5.0 and copyright year updates to 2025 for all extension packages
src/Kampute.HttpClient.Json/Kampute.HttpClient.Json.csproj System.Text.Json dependency changed to wildcard version "10.*"
src/Kampute.HttpClient.NewtonsoftJson/Kampute.HttpClient.NewtonsoftJson.csproj Newtonsoft.Json dependency changed to wildcard version "13.*"
tests//Kampute.HttpClient..Test.csproj Target framework upgraded from net8.0 to net10.0, NUnit3TestAdapter updated to 6.0.1
tests/Kampute.HttpClient.Test/TestHelpers/TestStream.cs New test helper for creating seekable/non-seekable streams in tests
tests/Kampute.HttpClient.Test/HttpRestClientTests.cs Added test for compressed content retry behavior, typo fix in test name, collection expression syntax updates
tests/Kampute.HttpClient.Test/ErrorHandlers/TransientHttpErrorHandlerTests.cs Comprehensive test coverage for new TransientHttpErrorHandler including constructor validation and retry behavior
tests/Kampute.HttpClient.Test/HttpContentExtensionsTests.cs Added tests for IsReusable with compressed content, replaced nested NonSeekableMemoryStream with shared TestStream
tests/Kampute.HttpClient.Test/HttpRequestMessageExtensionsTests.cs Refactored to use shared TestStream helper, removed duplicate test class definition
tests/**/*Tests.cs Converted Assert.Multiple to Assert.EnterMultipleScope for NUnit compatibility, collection expression syntax updates
.github/workflows/main.yml Updated to use .NET SDK 10.0.x, added keep_files: false to GitHub Pages deployment

@kampute kampute merged commit bd5356b into master Dec 21, 2025
1 check passed
@kampute kampute deleted the v2.5.0 branch December 21, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants