-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: Expose overloads of HttpContent.LoadIntoBufferAsync taking a CancellationToken #102659
Comments
@andrewhickman-aveva what is your motivation for filing this API proposal? Do you have any concrete use-case in mind? Does the current state limits you / your project? How impactfull it is? I don't have anything against this API, I'm just trying to understand the need for this and assign priority accordingly. |
This is motivated by a memory dump we received where a particular task was stuck calling this method, when it should have timed out. The reason we're using |
Triage: there were no concerns from our team about it. No reason not to expose this overloads. Putting in 9.0 time frame for the moment. I'll try to push it through API review. But as we don't have anyone else needing this, it might get push out 9.0. |
namespace System.Net.Http;
public partial class HttpContent
{
public Task LoadIntoBufferAsync(CancellationToken cancellationToken);
public Task LoadIntoBufferAsync(long maxBufferSize, CancellationToken cancellationToken);
} |
Background and motivation
HttpContent.LoadIntoBufferAsync
andHttpContent.LoadIntoBufferAsync(long)
currently forward to overloads which take a cancellation token, passingCancellationToken.None
.runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpContent.cs
Lines 476 to 477 in 5535e31
HttpClient
also uses this API but passes a cancellation token:runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
Line 487 in 5535e31
It would be useful for external consumers to be able to pass a cancellation token, similar to
HttpContent.CopyToAsync(Stream, CancellationToken
API Proposal
API Usage
Alternative Designs
If the
HttpContent
has been created byHttpClient
, it could internally track cancellation based on the token passed toSendAsync
. However I don't think this is consistent with existingHttpContent
methods likeCopyToAsync
.Risks
None
The text was updated successfully, but these errors were encountered: