Beispiel #1
0
        public GetRequest[] PreparingForCachingRequest(HttpJsonRequestFactory jsonRequestFactory)
        {
            cachedData = new CachedRequest[requests.Length];
            var requestsForServer = new GetRequest[requests.Length];

            Array.Copy(requests, 0, requestsForServer, 0, requests.Length);
            if (jsonRequestFactory.DisableHttpCaching == false && convention.ShouldCacheRequest(requestUri))
            {
                for (int i = 0; i < requests.Length; i++)
                {
                    var request = requests[i];
                    var cachingConfiguration = jsonRequestFactory.ConfigureCaching(url + request.UrlAndQuery,
                                                                                   (key, val) => request.Headers[key] = val);
                    cachedData[i] = cachingConfiguration.CachedRequest;
                    if (cachingConfiguration.SkipServerCheck)
                    {
                        requestsForServer[i] = null;
                    }
                }
            }
            allRequestsCanBeServedFromAggressiveCache = requestsForServer.All(x => x == null);
            return(requestsForServer);
        }