public ContentProducerContent(IContentProducer contentProducer, CancellationToken cancellationToken)
        {
            this.contentProducer   = contentProducer;
            this.cancellationToken = cancellationToken;

            Headers.ContentLength = contentProducer.Length;
        }
Пример #2
0
 public Request(
     [NotNull] string method,
     [NotNull] Uri url,
     [CanBeNull] IContentProducer contentProducer,
     [CanBeNull] Headers headers = default)
     : this(method, url, null, null, contentProducer, null, headers)
 {
 }
Пример #3
0
 private Request(
     [NotNull] string method,
     [NotNull] Uri url,
     [CanBeNull] CompositeContent compositeContent,
     [CanBeNull] IStreamContent streamContent,
     [CanBeNull] IContentProducer contentProducer,
     [CanBeNull] Content content,
     [CanBeNull] Headers headers)
 {
     Method           = method ?? throw new ArgumentNullException(nameof(method));
     Url              = url ?? throw new ArgumentNullException(nameof(url));
     CompositeContent = compositeContent;
     StreamContent    = streamContent;
     ContentProducer  = contentProducer;
     Content          = content;
     Headers          = headers;
 }
Пример #4
0
 public UserContentProducerWrapper(IContentProducer producer)
 {
     this.producer = producer;
     IsReusable    = producer.IsReusable;
 }
 private async Task SendBodyFromContentProducerAsync(IContentProducer contentProducer, WebRequestState state, CancellationToken cancellationToken)
 {
     var wrapper = new BufferingStreamWrapper(state.RequestStream);
     await contentProducer.ProduceAsync(wrapper, cancellationToken).ConfigureAwait(false);
 }
Пример #6
0
 public Request WithContent([NotNull] IContentProducer content)
 {
     return(new Request(Method, Url, content, content.Length.HasValue ? (Headers ?? Headers.Empty).Set(HeaderNames.ContentLength, content.Length.Value) : Headers));
 }