ShouldIgnoreCachePublic() public method

public ShouldIgnoreCachePublic ( CacheControlHeaderValue cacheControl, HttpRequestMessage request ) : bool
cacheControl System.Net.Http.Headers.CacheControlHeaderValue
request System.Net.Http.HttpRequestMessage
return bool
コード例 #1
0
        public bool Should_be_determined_from_MaxAge_and_cacheControl(int maxAge, bool? noCache, bool? noStore, int? cacheControlMaxAge, bool ignoreRevalidation)
        {
            CacheControlHeaderValue cacheControl = null;
            if (noCache.HasValue || noStore.HasValue || cacheControlMaxAge.HasValue)
            {
                cacheControl = new CacheControlHeaderValue
                {
                    NoCache = noCache ?? false,
                    NoStore = noStore ?? false,
                };

                if (cacheControlMaxAge.HasValue)
                {
                    cacheControl.MaxAge = TimeSpan.FromSeconds(cacheControlMaxAge.Value);
                }
            }
            var att = new OutputCacheAttributeWithPublicMethods
            {
                MaxAge = (uint)maxAge,
                IgnoreRevalidationRequest = ignoreRevalidation
            };

            // Action
            return att.ShouldIgnoreCachePublic(cacheControl, new HttpRequestMessage());
        }
コード例 #2
0
        public bool Should_be_determined_from_MaxAge_and_cacheControl(int maxAge, bool?noCache, bool?noStore, int?cacheControlMaxAge, bool ignoreRevalidation)
        {
            CacheControlHeaderValue cacheControl = null;

            if (noCache.HasValue || noStore.HasValue || cacheControlMaxAge.HasValue)
            {
                cacheControl = new CacheControlHeaderValue
                {
                    NoCache = noCache ?? false,
                    NoStore = noStore ?? false,
                };

                if (cacheControlMaxAge.HasValue)
                {
                    cacheControl.MaxAge = TimeSpan.FromSeconds(cacheControlMaxAge.Value);
                }
            }
            var att = new OutputCacheAttributeWithPublicMethods
            {
                MaxAge = (uint)maxAge,
                IgnoreRevalidationRequest = ignoreRevalidation
            };

            // Action
            return(att.ShouldIgnoreCachePublic(cacheControl, new HttpRequestMessage()));
        }
コード例 #3
0
        public void Should_return_true_if_request_property_has_key_telling_no_cache()
        {
            var att = new OutputCacheAttributeWithPublicMethods
            {
                MaxAge = 10
            };
            var request = new HttpRequestMessage
            {
                Properties = {{$"{WebApiExtensions.__flatwhite_dont_cache}_for_test", true}}
            };

            // Action
            Assert.IsTrue(att.ShouldIgnoreCachePublic(new CacheControlHeaderValue(), request));
        }
コード例 #4
0
        public void Should_return_true_if_request_property_has_key_telling_no_cache()
        {
            var att = new OutputCacheAttributeWithPublicMethods
            {
                MaxAge = 10
            };
            var request = new HttpRequestMessage
            {
                Properties = { { $"{WebApiExtensions.__flatwhite_dont_cache}_for_test", true } }
            };

            // Action
            Assert.IsTrue(att.ShouldIgnoreCachePublic(new CacheControlHeaderValue(), request));
        }