Exemplo n.º 1
0
        public async Task <IEnumerable <Response> > BatchAsync(IBatchRequest request)
        {
            var message = request.CreateMessage();

            _credentialBuilder?.Build(_httpClient, message);

            var response = await _httpClient.SendAsync(message);

            if (!response.Content.IsMimeMultipartContent())
            {
                return new[] { await ParseAsync(response.StatusCode, response.Content, response.Headers) }
            }
            ;

            var multipart = await response.Content.ReadAsMultipartAsync();

            return(await ParseMultiAsync(multipart, response.Headers));
        }
Exemplo n.º 2
0
        public async Task <IReadOnlyList <Response> > BatchAsync(IBatchRequest request, CancellationToken cancellationToken = default, bool?notfoundIsSuccess = null)
        {
            var message = request.CreateMessage();

            _credentialBuilder?.Build(_httpClient, message);

            var response = await _httpClient.SendAsync(message, cancellationToken);

            if (!response.Content.IsMimeMultipartContent())
            {
                return new[] { await ParseAsync(response.StatusCode, response.Content, response.Headers, notfoundIsSuccess ?? NotFoundIsSuccess) }
            }
            ;

            var multipart = await response.Content.ReadAsMultipartAsync(cancellationToken);

            return(await ParseMultiAsync(multipart, response.Headers, cancellationToken, notfoundIsSuccess));
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <Response> > BatchAsync(IBatchRequest request)
        {
            var message = request.CreateMessage();

            message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            _credentialBuilder?.Build(_httpClient, message);

            var response = await _httpClient.SendAsync(message);

            if (!response.Content.IsMimeMultipartContent())
            {
                return new[] { await ParseAsync(response.StatusCode, response.Content) }
            }
            ;

            var multipart = await response.Content.ReadAsMultipartAsync();

            return(await ParseMultiAsync(multipart));
        }