protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context) { _originStream = await _originContent.ReadAsStreamAsync().ConfigureAwait(false); StreamReader = new PeekableStreamReader(new CancelableStream(_originStream, _cancellationToken)); var firstLine = await StreamReader.PeekLineAsync().ConfigureAwait(false); var writer = new StreamWriter(stream); await writer.WriteAsync(firstLine).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); }
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context) { _originStream = await _originContent.ReadAsStreamAsync(); StreamReader = new PeekableStreamReader(_originStream); var firstLine = await StreamReader.PeekLineAsync(); var writer = new StreamWriter(stream); // using (writer) // leave open { await writer.WriteAsync(firstLine); await writer.FlushAsync(); } }