private void ConfigureCaching(string url, string method, DocumentConvention convention, HttpJsonRequest request) { request.ShouldCacheRequest = convention.ShouldCacheRequest(url); if (!request.ShouldCacheRequest || method != "GET") return; var cachedRequest = (CachedRequest)cache.Get(url); if (cachedRequest == null) return; request.CachedRequestDetails = cachedRequest; request.WebRequest.Headers["If-None-Match"] = cachedRequest.Headers["ETag"]; }
/// <summary> /// Creates the HTTP json request. /// </summary> /// <param name="self">The self.</param> /// <param name="url">The URL.</param> /// <param name="method">The method.</param> /// <param name="metadata">The metadata.</param> /// <param name="credentials">The credentials.</param> /// <param name="convention">The document conventions governing this request</param> /// <returns></returns> public static HttpJsonRequest CreateHttpJsonRequest(object self, string url, string method, JObject metadata, ICredentials credentials, DocumentConvention convention) { var request = new HttpJsonRequest(url, method, metadata, credentials, convention.ShouldCacheRequest(url)); ConfigureRequest(self, new WebRequestEventArgs { Request = request.webRequest }); return request; }