parent
9f0beec63a
commit
9c597aad90
1 changed files with 533 additions and 37 deletions
26
src/Common/Polyfills/System/Net/Http/HttpClientExtensions.cs
Normal file
26
src/Common/Polyfills/System/Net/Http/HttpClientExtensions.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
namespace System.Net.Http;
|
||||
|
||||
internal static class HttpClientExtensions
|
||||
{
|
||||
public static async Task<Stream> ReadAsStreamAsync(this HttpContent content, CancellationToken cancellationToken)
|
||||
{
|
||||
if (content is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(content));
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await content.ReadAsStreamAsync();
|
||||
}
|
||||
|
||||
public static async Task<string> ReadAsStringAsync(this HttpContent content, CancellationToken cancellationToken)
|
||||
{
|
||||
if (content is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(content));
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return await content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue