示例#1
0
        public static HttpClientHandler GetHttpClientHandler(IApiProxyConfiguration configuration,
                                                             ICredentials credentials = null, EventHandler <RequestReceivedEventArgs> requestReceivedEventHandler = null)
        {
            var clientHandler = new ApiProxyClientHandler(configuration)
            {
                Credentials     = credentials,
                PreAuthenticate = true
            };

            if (requestReceivedEventHandler != null)
            {
                clientHandler.RequestReceived += requestReceivedEventHandler;
            }

            return(clientHandler);
        }
示例#2
0
        public static HttpClient GetHttpClient(IApiProxyConfiguration configuration, ICredentials credentials = null, EventHandler <RequestReceivedEventArgs> requestReceivedEventHandler = null)
        {
            var baseUri       = configuration.DefaultApiAddress ?? new Uri("https://localhost/");
            var clientHandler = new ApiProxyClientHandler(configuration)
            {
                Credentials     = credentials,
                PreAuthenticate = true
            };

            if (requestReceivedEventHandler != null)
            {
                clientHandler.RequestReceived += requestReceivedEventHandler;
            }

            return(new HttpClient(clientHandler)
            {
                BaseAddress = baseUri
            });
        }