4using System.Threading.Tasks;
28 public static async ValueTask<CachedResponseStream>
Create(HttpResponseMessage response)
31 throw new ArgumentNullException(nameof(response));
35 var content = response.Content;
36 response.Content =
null;
40 var
responseStream = await content.ReadAsStreamAsync().ConfigureAwait(
false);
67 set => responseStream.Position = value;
74 public override int Read(
byte[] buffer,
int offset,
int count) =>
responseStream.Read(buffer, offset, count);
77 public override long Seek(
long offset, SeekOrigin origin) =>
responseStream.Seek(offset, origin);
83 public override void Write(
byte[] buffer,
int offset,
int count) =>
responseStream.Write(buffer, offset, count);
86 protected override void Dispose(
bool disposing)
88 base.Dispose(disposing);
Caches the Stream from a HttpResponseMessage for later use.
override void Dispose(bool disposing)
override int Read(byte[] buffer, int offset, int count)
static async ValueTask< CachedResponseStream > Create(HttpResponseMessage response)
Asyncronously creates a new CachedResponseStream.
override void Write(byte[] buffer, int offset, int count)
override void SetLength(long value)
readonly HttpContent responseContent
The HttpContent for the CachedResponseStream.
readonly Stream responseStream
The reponse content Stream.
CachedResponseStream(HttpContent responseContent, Stream responseStream)
Initializes a new instance of the CachedResponseStream class.
override long Seek(long offset, SeekOrigin origin)