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);
}
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 forCreateContentReadStreamAsyncis needed (see comment).The default implementation would drop the
CancellationTokenand call the existing overload. This is the behavior that was decided forSerializeToStreamAsyncin dotnet/corefx#9071.HttpContentalso lacks support for cancelingCopyToAsync.Proposal: