Dispose HttpResponseMessage and HttpContent in HTTP client proxy#25478
Merged
Conversation
ABP dynamic HTTP client proxy uses HttpCompletionOption.ResponseHeadersRead, but several paths in ClientProxyBase and DynamicHttpProxyInterceptor dropped the response without disposing it, leaving the underlying connection occupied until the server closed it or the client timed out. Fixes #25475
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a connection/resource leak in ABP’s dynamic HTTP client proxy when using HttpCompletionOption.ResponseHeadersRead by ensuring responses/contents are disposed on non-success and “no return value” code paths, so connections aren’t held open unnecessarily (Fixes #25475).
Changes:
- Dispose the returned
HttpContentfor void-returning proxy methods (both interceptor and base proxy paths). - Ensure
HttpResponseMessageis disposed when throwing for non-success responses to deterministically release the underlying connection. - Add regression tests verifying
HttpContentis disposed for non-ABP error responses and successful responses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/ClientProxyResponseDisposal_Tests.cs | Adds tests asserting HttpContent is disposed on key success/error paths. |
| framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs | Disposes HttpContent for void-returning dynamic proxy invocations. |
| framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyBase.cs | Disposes response/content on void return, JSON/string parsing, and non-success throw paths. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rel-10.4 #25478 +/- ##
============================================
- Coverage 49.44% 49.40% -0.04%
============================================
Files 3670 3670
Lines 123599 123611 +12
Branches 9453 9453
============================================
- Hits 61111 61069 -42
- Misses 60654 60715 +61
+ Partials 1834 1827 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
EngincanV
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25475
ABP HTTP client proxy uses
HttpCompletionOption.ResponseHeadersRead, but several paths dropped the response without disposing it and held the connection open. DisposeHttpResponseMessage/HttpContenton these paths.