< Summary

Class:Azure.Identity.HttpPipelineClientFactory
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\HttpPipelineClientFactory.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:56
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
GetHttpClient()-100%100%
.ctor(...)-100%100%
SendAsync()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\HttpPipelineClientFactory.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using Azure.Core.Pipeline;
 5using Microsoft.Identity.Client;
 6using System;
 7using System.Collections.Generic;
 8using System.Linq;
 9using System.Net.Http;
 10using System.Text;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure.Core;
 14
 15namespace Azure.Identity
 16{
 17    /// <summary>
 18    /// This class is an HttpClient factory which creates an HttpClient which delegates it's transport to an HttpPipelin
 19    /// </summary>
 20    internal class HttpPipelineClientFactory : IMsalHttpClientFactory
 21    {
 22        private readonly HttpPipeline _pipeline;
 23
 13624        public HttpPipelineClientFactory(HttpPipeline pipeline)
 25        {
 13626            _pipeline = pipeline;
 13627        }
 28
 29        public HttpClient GetHttpClient()
 30        {
 21631            return new HttpClient(new PipelineHttpMessageHandler(_pipeline));
 32        }
 33
 34        /// <summary>
 35        /// An HttpMessageHandler which delegates SendAsync to a specified HttpPipeline.
 36        /// </summary>
 37        private class PipelineHttpMessageHandler : HttpMessageHandler
 38        {
 39            private readonly HttpPipeline _pipeline;
 40
 21641            public PipelineHttpMessageHandler(HttpPipeline pipeline)
 42            {
 21643                _pipeline = pipeline;
 21644            }
 45
 46            protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken c
 47            {
 21648                Request pipelineRequest = await request.ToPipelineRequestAsync(_pipeline).ConfigureAwait(false);
 49
 21650                Response pipelineResponse = await _pipeline.SendRequestAsync(pipelineRequest, cancellationToken).Configu
 51
 20852                return pipelineResponse.ToHttpResponseMessage();
 20853            }
 54        }
 55    }
 56}