示例#1
0
        protected RestClientBase(string baseAddress, Encoding encoding, IHttpCacheStore httpCacheStore, string userAgent = null)
        {
            if (encoding == null)
            {
                throw new NullReferenceException();
            }

            if (httpCacheStore != null)
            {
                HttpClient = new HttpClient
                             (
                    new HttpCacheHandler(httpCacheStore)
                {
                    InnerHandler = new HttpClientHandler()
                }
                             );
            }
            else
            {
                HttpClient = new HttpClient();
            }
            HttpClient.BaseAddress = new Uri(baseAddress);
            HttpClient.Timeout     = TimeSpan.FromMilliseconds(10000);
//			HttpClient.DefaultRequestHeaders.UserAgent = userAgent;

            UserAgent   = userAgent;
            BaseAddress = baseAddress;
            Encoding    = encoding;
        }
示例#2
0
		public HttpCacheHandler(IHttpCacheStore httpCacheStore)
		{
			if (httpCacheStore == null)
			{
				throw new NullReferenceException();
			}
			_httpCacheStore = httpCacheStore;
		}
示例#3
0
 public HttpCacheHandler(IHttpCacheStore httpCacheStore)
 {
     if (httpCacheStore == null)
     {
         throw new NullReferenceException();
     }
     _httpCacheStore = httpCacheStore;
 }