/* * Reset based on the cached vary headers. */ internal void ResetFromHeaders(String[] headers) { int i, n; if (headers == null) { _isModified = false; _varyStar = false; _headers = null; } else { _isModified = true; if (headers[0].Equals("*")) { Debug.Assert(headers.Length == 1, "headers.Length == 1"); _varyStar = true; _headers = null; } else { _varyStar = false; _headers = new HttpDictionary(); for (i = 0, n = headers.Length; i < n; i++) { _headers.SetValue(headers[i], headers[i]); } } } }
/// <summary> /// Set the Headers in Cache Vary /// </summary> /// <param name="headers"></param> public void SetHeaders(string[] headers) { int i, n; if (headers == null) { _isModified = false; _varyStar = false; _headers = null; } else { _isModified = true; if (headers[0].Equals("*")) { Debug.Assert(headers.Length == 1, "headers.Length == 1"); _varyStar = true; _headers = null; } else { _varyStar = false; _headers = new HttpDictionary(); for (i = 0, n = headers.Length; i < n; i++) { _headers.SetValue(headers[i], headers[i]); } } } }
/* * Reset based on the cached vary headers. */ internal void ResetFromParams(String[] parameters) { int i, n; Reset(); if (parameters != null) { _isModified = true; if (parameters[0].Length == 0) { Debug.Assert(parameters.Length == 1, "parameters.Length == 1"); IgnoreParams = true; } else if (parameters[0].Equals("*")) { Debug.Assert(parameters.Length == 1, "parameters.Length == 1"); _paramsStar = true; } else { _parameters = new HttpDictionary(); for (i = 0, n = parameters.Length; i < n; i++) { _parameters.SetValue(parameters[i], parameters[i]); } } } }
// // Public methods and properties // /// <include file='doc\HttpCacheParams.uex' path='docs/doc[@for="HttpCacheVaryByParams.this"]/*' /> /// <devdoc> /// <para> Default property. /// Indexed property indicating that a cache should (or should not) vary according /// to a custom header.</para> /// </devdoc> public bool this[String header] { get { if (header == null) { throw new ArgumentNullException("header"); } if (header.Length == 0) { return(_ignoreParams == 1); } else { return(_paramsStar || (_parameters != null && _parameters.GetValue(header) != null)); } } set { if (header == null) { throw new ArgumentNullException("header"); } if (header.Length == 0) { IgnoreParams = value; } /* * Since adding a Vary parameter is more restrictive, we don't * want components to be able to set a Vary parameter to false * if another component has set it to true. */ else if (value) { _isModified = true; _ignoreParams = 0; if (header.Equals("*")) { _paramsStar = true; _parameters = null; } else { // set value to header if true or null if false if (!_paramsStar) { if (_parameters == null) { _parameters = new HttpDictionary(); } _parameters.SetValue(header, header); } } } } }
/* * Vary by a given header */ /// <include file='doc\HttpCacheVary.uex' path='docs/doc[@for="HttpCacheVaryByHeaders.this"]/*' /> /// <devdoc> /// <para> Default property. /// Indexed property indicating that a cache should (or should not) vary according /// to a custom header.</para> /// </devdoc> public bool this[String header] { get { if (header == null) { throw new ArgumentNullException("header"); } if (header.Equals("*")) { return(_varyStar); } else { return(_headers != null && _headers.GetValue(header) != null); } } set { if (header == null) { throw new ArgumentNullException("header"); } /* * Since adding a Vary header is more restrictive, we don't * want components to be able to set a Vary header to false * if another component has set it to true. */ if (value == false) { return; } _isModified = true; if (header.Equals("*")) { VaryByUnspecifiedParameters(); } else { // set value to header if true or null if false if (!_varyStar) { if (_headers == null) { _headers = new HttpDictionary(); } _headers.SetValue(header, header); } } } }
/// <summary> /// Set the Parameters in Cache Vary /// </summary> /// <param name="parameters"></param> public void SetParams(string[] parameters) { int i, n; Reset(); if (parameters != null) { _isModified = true; if (parameters[0].Length == 0) { Debug.Assert(parameters.Length == 1, "parameters.Length == 1"); IgnoreParams = true; } else if (parameters[0].Equals("*")) { Debug.Assert(parameters.Length == 1, "parameters.Length == 1"); _paramsStar = true; } else { _parameters = new HttpDictionary(); for (i = 0, n = parameters.Length; i < n; i++) { _parameters.SetValue(parameters[i], parameters[i]); } } } }
/* * Reset based on a cached response. Includes data needed to generate * header for a cached response. */ internal void ResetFromHttpCachePolicySettings( HttpCachePolicySettings settings, DateTime utcTimestampRequest) { int i, n; string[] fields; _utcTimestampRequest = utcTimestampRequest; _varyByContentEncodings.ResetFromContentEncodings(settings.VaryByContentEncodings); _varyByHeaders.ResetFromHeaders(settings.VaryByHeaders); _varyByParams.ResetFromParams(settings.VaryByParams); _isModified = settings.IsModified; _hasSetCookieHeader = settings.hasSetCookieHeader; _noServerCaching = settings.NoServerCaching; _cacheExtension = settings.CacheExtension; _noTransforms = settings.NoTransforms; _ignoreRangeRequests = settings.IgnoreRangeRequests; _varyByCustom = settings.VaryByCustom; _cacheability = settings.CacheabilityInternal; _noStore = settings.NoStore; _utcExpires = settings.UtcExpires; _isExpiresSet = settings.IsExpiresSet; _maxAge = settings.MaxAge; _isMaxAgeSet = settings.IsMaxAgeSet; _proxyMaxAge = settings.ProxyMaxAge; _isProxyMaxAgeSet = settings.IsProxyMaxAgeSet; _slidingExpiration = settings.SlidingExpirationInternal; _slidingDelta = settings.SlidingDelta; _utcTimestampCreated = settings.UtcTimestampCreated; _validUntilExpires = settings.ValidUntilExpiresInternal; _allowInHistory = settings.AllowInHistoryInternal; _revalidation = settings.Revalidation; _utcLastModified = settings.UtcLastModified; _isLastModifiedSet = settings.IsLastModifiedSet; _etag = settings.ETag; _generateLastModifiedFromFiles = settings.GenerateLastModifiedFromFiles; _generateEtagFromFiles = settings.GenerateEtagFromFiles; _omitVaryStar = settings.OmitVaryStarInternal; _hasUserProvidedDependencies = settings.HasUserProvidedDependencies; _useCachedHeaders = true; _headerCacheControl = settings.HeaderCacheControl; _headerPragma = settings.HeaderPragma; _headerExpires = settings.HeaderExpires; _headerLastModified = settings.HeaderLastModified; _headerEtag = settings.HeaderEtag; _headerVaryBy = settings.HeaderVaryBy; _noMaxAgeInCacheControl = false; fields = settings.PrivateFields; if (fields != null) { _privateFields = new HttpDictionary(); for (i = 0, n = fields.Length; i < n; i++) { _privateFields.SetValue(fields[i], fields[i]); } } fields = settings.NoCacheFields; if (fields != null) { _noCacheFields = new HttpDictionary(); for (i = 0, n = fields.Length; i < n; i++) { _noCacheFields.SetValue(fields[i], fields[i]); } } if (settings.ValidationCallbackInfo != null) { _validationCallbackInfo = new ArrayList(); for (i = 0, n = settings.ValidationCallbackInfo.Length; i < n; i++) { _validationCallbackInfo.Add(new ValidationCallbackInfo( settings.ValidationCallbackInfo[i].handler, settings.ValidationCallbackInfo[i].data)); } } }