public void SetStream(HttpContentReadStream stream) { Debug.Assert(stream != null); Debug.Assert(stream.CanRead); _stream = stream; }
internal sealed override async Task SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken) { Debug.Assert(stream != null); using (HttpContentReadStream contentStream = ConsumeStream()) { const int BufferSize = 8192; await contentStream.CopyToAsync(stream, BufferSize, cancellationToken).ConfigureAwait(false); } }
private HttpContentReadStream ConsumeStream() { if (_stream == null) { throw new InvalidOperationException(SR.net_http_content_stream_already_read); } HttpContentReadStream stream = _stream; _stream = null; return(stream); }
private HttpContentReadStream ConsumeStream() { if (_stream == null) { throw new InvalidOperationException("content already consumed"); } HttpContentReadStream stream = _stream; _stream = null; return(stream); }
protected override void Dispose(bool disposing) { if (disposing) { if (_stream != null) { _stream.Dispose(); _stream = null; } } base.Dispose(disposing); }