예제 #1
0
        /*
         * //
         * protected RequestCacheValidator(): this(false, TimeSpan.FromDays(1))
         * {
         * }
         */

        protected RequestCacheValidator(bool strictCacheErrors, TimeSpan unspecifiedMaxAge)
        {
            _StrictCacheErrors    = strictCacheErrors;
            _UnspecifiedMaxAge    = unspecifiedMaxAge;
            _ValidationStatus     = CacheValidationStatus.DoNotUseCache;
            _CacheFreshnessStatus = CacheFreshnessStatus.Undefined;
        }
        //
        //
        //
        private void ValidateFreshness(RequestCacheEntry fetchEntry)
        {
            _Validator.FetchCacheEntry(fetchEntry);

            if (_Validator.CacheStream == null || _Validator.CacheStream == Stream.Null)
            {
                if (Logging.On)
                {
                    Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_entry_not_found_freshness_undefined, "ValidateFreshness()"));
                }
                _Validator.SetFreshnessStatus(CacheFreshnessStatus.Undefined);
                return;
            }

            if (Logging.On)
            {
                if (Logging.IsVerbose(Logging.RequestCache))
                {
                    Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_dumping_cache_context));

                    if (fetchEntry == null)
                    {
                        Logging.PrintInfo(Logging.RequestCache, "<null>");
                    }
                    else
                    {
                        string[] context = fetchEntry.ToString(Logging.IsVerbose(Logging.RequestCache)).Split(RequestCache.LineSplits);

                        for (int i = 0; i < context.Length; ++i)
                        {
                            if (context[i].Length != 0)
                            {
                                Logging.PrintInfo(Logging.RequestCache, context[i]);
                            }
                        }
                    }
                }
            }

            CacheFreshnessStatus result = _Validator.ValidateFreshness();

            _Validator.SetFreshnessStatus(result);
            _IsCacheFresh = result == CacheFreshnessStatus.Fresh;

            if (Logging.On)
            {
                Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_result, "ValidateFreshness()", result.ToString()));
            }
        }
예제 #3
0
        /*-------------- internal members -------------*/
        //
        internal void FetchRequest(Uri uri, WebRequest request)
        {
            _Request              = request;
            _Policy               = request.CachePolicy;
            _Response             = null;
            _ResponseCount        = 0;
            _ValidationStatus     = CacheValidationStatus.DoNotUseCache;
            _CacheFreshnessStatus = CacheFreshnessStatus.Undefined;
            _CacheStream          = null;
            _CacheStreamOffset    = 0L;
            _CacheStreamLength    = 0L;

            if (!uri.Equals(_Uri))
            {
                // it's changed from previous call
                _CacheKey = uri.GetParts(UriComponents.AbsoluteUri, UriFormat.Unescaped);
            }
            _Uri = uri;
        }
 private void ValidateFreshness(RequestCacheEntry fetchEntry)
 {
     this._Validator.FetchCacheEntry(fetchEntry);
     if ((this._Validator.CacheStream == null) || (this._Validator.CacheStream == Stream.Null))
     {
         if (Logging.On)
         {
             Logging.PrintInfo(Logging.RequestCache, SR.GetString("net_log_cache_entry_not_found_freshness_undefined", new object[] { "ValidateFreshness()" }));
         }
         this._Validator.SetFreshnessStatus(CacheFreshnessStatus.Undefined);
     }
     else
     {
         if (Logging.On && Logging.IsVerbose(Logging.RequestCache))
         {
             Logging.PrintInfo(Logging.RequestCache, SR.GetString("net_log_cache_dumping_cache_context"));
             if (fetchEntry == null)
             {
                 Logging.PrintInfo(Logging.RequestCache, "<null>");
             }
             else
             {
                 string[] strArray = fetchEntry.ToString(Logging.IsVerbose(Logging.RequestCache)).Split(RequestCache.LineSplits);
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     if (strArray[i].Length != 0)
                     {
                         Logging.PrintInfo(Logging.RequestCache, strArray[i]);
                     }
                 }
             }
         }
         CacheFreshnessStatus status = this._Validator.ValidateFreshness();
         this._Validator.SetFreshnessStatus(status);
         this._IsCacheFresh = status == CacheFreshnessStatus.Fresh;
         if (Logging.On)
         {
             Logging.PrintInfo(Logging.RequestCache, SR.GetString("net_log_cache_result", new object[] { "ValidateFreshness()", status.ToString() }));
         }
     }
 }
 internal void SetFreshnessStatus(CacheFreshnessStatus status)
 {
     _CacheFreshnessStatus = status;
 }
        /*-------------- internal members -------------*/
        //
        internal void FetchRequest(Uri uri, WebRequest request)
        {
            _Request = request;
            _Policy  = request.CachePolicy;
            _Response = null;
            _ResponseCount = 0;
            _ValidationStatus     = CacheValidationStatus.DoNotUseCache;
            _CacheFreshnessStatus = CacheFreshnessStatus.Undefined;
            _CacheStream          = null;
            _CacheStreamOffset    = 0L;
            _CacheStreamLength    = 0L;

            if (!uri.Equals(_Uri))
            {
                // it's changed from previous call
                _CacheKey = uri.GetParts(UriComponents.AbsoluteUri, UriFormat.Unescaped);
            }
            _Uri = uri;
        }
        /*
        //                                    
        protected RequestCacheValidator(): this(false, TimeSpan.FromDays(1))
        {
        }
        */

        protected RequestCacheValidator(bool strictCacheErrors, TimeSpan unspecifiedMaxAge)
        {
            _StrictCacheErrors    = strictCacheErrors;
            _UnspecifiedMaxAge    = unspecifiedMaxAge;
            _ValidationStatus     = CacheValidationStatus.DoNotUseCache;
            _CacheFreshnessStatus = CacheFreshnessStatus.Undefined;
        }
예제 #8
0
 internal void SetFreshnessStatus(CacheFreshnessStatus status)
 {
     _CacheFreshnessStatus = status;
 }