-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Http
Milestone
Description
Part of a series of issues adding cancellation support to HttpContent and HttpClient:
https://github.com/dotnet/corefx/issues/32615, https://github.com/dotnet/corefx/issues/9071
In order to implement HttpContent.ReadAsStreamAsync(CancellationToken) from dotnet/corefx#32615, an additional overload for CreateContentReadStreamAsync is needed (see comment).
The default implementation would drop the CancellationToken and call the existing overload. This is the behavior that was decided for SerializeToStreamAsync in dotnet/corefx#9071.
HttpContent also lacks support for canceling CopyToAsync.
Proposal:
partial class HttpContent
{
// Existing
protected virtual Task<Stream> CreateContentReadStreamAsync();
// New
protected virtual Task<Stream> CreateContentReadStreamAsync(CancellationToken cancellationToken);
// Existing
public Task CopyToAsync(Stream stream);
public Task CopyToAsync(Stream stream, TransportContext context);
internal Task CopyToAsync(Stream stream, TransportContext context, CancellationToken cancellationToken);
// New
public Task CopyToAsync(Stream stream, CancellationToken cancellationToken);
// Change internal => public
public Task CopyToAsync(Stream stream, TransportContext context, CancellationToken cancellationToken);
}Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Http