public override Task Copy(Stream target)
 {
     try
     {
         var wrapper = new BufferingStreamWrapper(target);
         return(contentProducer.ProduceAsync(wrapper, cancellationToken));
     }
     catch (ContentAlreadyUsedException)
     {
         throw;
     }
     catch (OperationCanceledException)
     {
         throw;
     }
     catch (BufferingStreamWrapperException error)
     {
         // ReSharper disable once PossibleNullReferenceException
         throw error.InnerException;
     }
     catch (Exception error)
     {
         throw new UserContentProducerException($"Failed to read from user-provided content producer of type '{contentProducer.GetType().Name}'.", error);
     }
 }
 private async Task SendBodyFromContentProducerAsync(IContentProducer contentProducer, WebRequestState state, CancellationToken cancellationToken)
 {
     var wrapper = new BufferingStreamWrapper(state.RequestStream);
     await contentProducer.ProduceAsync(wrapper, cancellationToken).ConfigureAwait(false);
 }