Skip to content

Feature/custom http client delegates - #218

Merged
bezzad merged 18 commits into
developfrom
feature/custom_HttpClient_delegates
Mar 11, 2026
Merged

Feature/custom http client delegates#218
bezzad merged 18 commits into
developfrom
feature/custom_HttpClient_delegates

Conversation

@bezzad

@bezzad bezzad commented Mar 10, 2026

Copy link
Copy Markdown
Owner

This pull request adds comprehensive support for injecting custom HttpClient and HttpMessageHandler instances into the Downloader library, enabling advanced scenarios like integration with IHttpClientFactory, HTTP caching, and custom authentication. It updates the documentation to explain these new features, introduces a suite of integration tests to ensure correct behavior, and improves test configuration.

The most important changes are:

Custom HttpClient/HttpMessageHandler Support:

  • Added the ability to inject a custom HttpClient or HttpMessageHandler via the DownloadConfiguration and DownloadBuilder APIs, allowing users to control HTTP behavior for advanced use cases. [1] [2] [3] [4]

Documentation Updates:

  • Expanded README.md with detailed instructions and code samples for using custom HTTP clients and handlers, including builder API usage and precedence rules. [1] [2]
  • Improved documentation clarity and formatting in other sections, such as build instructions, test running, and download resumption. [1] [2] [3] [4] [5] [6] [7] [8]

Testing Enhancements:

  • Added CustomHttpClientIntegrationTest.cs with thorough integration tests covering all combinations of custom client/handler injection, builder API usage, and precedence logic.
  • Added xunit.runner.json to configure test runner diagnostics and long-running test thresholds.
  • Updated the test project file to include the new runner configuration.

These changes make the Downloader library more flexible for real-world enterprise and advanced usage scenarios, while ensuring robust test coverage and improved documentation.

@bezzad
bezzad requested a review from Copilot March 10, 2026 16:01
@bezzad bezzad self-assigned this Mar 10, 2026
@bezzad bezzad added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 10, 2026
@bezzad bezzad linked an issue Mar 10, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class support for supplying a custom HttpClient or HttpMessageHandler to the downloader pipeline, enabling advanced scenarios like IHttpClientFactory usage, delegating handlers (caching/auth), and custom connection pooling.

Changes:

  • Introduces CustomHttpClientFactory and CustomHttpMessageHandlerFactory on DownloadConfiguration and wires them into SocketClient.
  • Adds fluent builder methods to configure the above factories via DownloadBuilder.
  • Adds integration tests and README documentation for the new injection options.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Downloader/SocketClient.cs Uses injected HttpClient/handler factories when provided; minor header initialization tweak.
src/Downloader/DownloadConfiguration.cs Adds public configuration delegates for custom HttpClient / HttpMessageHandler.
src/Downloader/DownloadBuilder.cs Adds fluent methods to set the new configuration delegates.
src/Downloader.Test/xunit.runner.json Configures xUnit runner diagnostics/long-running threshold.
src/Downloader.Test/IntegrationTests/CustomHttpClientIntegrationTest.cs Adds integration tests covering custom client/handler injection and precedence rules.
src/Downloader.Test/Downloader.Test.csproj Ensures xunit.runner.json is copied to test output.
README.md Documents how to use custom HttpClient/handler injection and builder equivalents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Downloader/SocketClient.cs Outdated
Comment thread src/Downloader/SocketClient.cs
Comment thread src/Downloader.Test/IntegrationTests/CustomHttpClientIntegrationTest.cs Outdated
…onTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Downloader/DownloadConfiguration.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Downloader/DownloadConfiguration.cs
Comment thread src/Downloader/SocketClient.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Downloader/SocketClient.cs
Comment thread src/Downloader/SocketClient.cs
Comment thread .github/workflows/dotnet-windows.yml Outdated
Comment thread .github/workflows/dotnet-ubuntu.yml Outdated
Comment thread .github/workflows/dotnet-macos.yml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Downloader/SocketClient.cs
Comment thread src/Downloader/SocketClient.cs
Comment thread src/Downloader/SocketClient.cs Outdated
@bezzad
bezzad merged commit d82a1a9 into develop Mar 11, 2026
6 of 8 checks passed
@bezzad
bezzad deleted the feature/custom_HttpClient_delegates branch March 11, 2026 08:58
@bezzad
bezzad restored the feature/custom_HttpClient_delegates branch March 12, 2026 10:02
@bezzad
bezzad deleted the feature/custom_HttpClient_delegates branch March 14, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allows callers to pass delegates to use a custom HttpClient

2 participants