コード例 #1
0
        private HttpClient CreateClientWithMessageHandlerCache()
        {
            var httpClientHandler = TestServer.CreateServer();

            var clientHandler = new PrivateCacheHandler(httpClientHandler, new HttpCache(new InMemoryContentStore()));
            var client        = new HttpClient(clientHandler)
            {
                BaseAddress = _BaseAddress
            };

            return(client);
        }
コード例 #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BaseClient" /> class.
        /// </summary>
        /// <param name="baseEndpoint">The base endpoint.</param>
        /// <param name="handler">Message processing handler</param>
        public BaseClient(Uri baseEndpoint, HttpMessageHandler handler = null)
        {
            BaseAddress     = baseEndpoint;
            this._httpCache = new HttpCache(_store);
            var cachingHandler = new PrivateCacheHandler(handler ?? new HttpClientHandler(), this._httpCache);

            //httpClient = HttpClientFactory.Create(caheHandler);
            this._httpClient = new HttpClient(cachingHandler)
            {
                Timeout = TimeSpan.FromSeconds(90)
            };
            this._disposed = false;
        }