// Token: 0x06000280 RID: 640 RVA: 0x0000CDE8 File Offset: 0x0000AFE8
        public static BackEndCookieEntryBase Parse(string entryValue)
        {
            BackEndCookieEntryBase result = null;

            if (!BackEndCookieEntryParser.TryParse(entryValue, out result))
            {
                throw new InvalidBackEndCookieException();
            }
            return(result);
        }
        // Token: 0x060004C7 RID: 1223 RVA: 0x0001A630 File Offset: 0x00018830
        private void SanitizeCookie(HttpCookie backEndCookie)
        {
            if (backEndCookie == null)
            {
                return;
            }
            if (this.removeBackEndCookieEntry && base.AnchoredRoutingTarget != null)
            {
                string text = base.AnchoredRoutingTarget.AnchorMailbox.ToCookieKey();
                backEndCookie.Values.Remove(text);
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; Removed cookie entry with key {1}.", base.TraceContext, text);
                }
            }
            ExDateTime exDateTime = ExDateTime.UtcNow.AddYears(-30);
            int        num        = 0;

            for (int i = backEndCookie.Values.Count - 1; i >= 0; i--)
            {
                bool flag = true;
                BackEndCookieEntryBase backEndCookieEntryBase = null;
                if (num < this.MaxBackEndCookieEntries && BackEndCookieEntryParser.TryParse(backEndCookie.Values[i], out backEndCookieEntryBase))
                {
                    flag = backEndCookieEntryBase.Expired;
                    if (!flag && this.removeBackEndCookieEntry && base.AnchoredRoutingTarget != null && backEndCookieEntryBase.ShouldInvalidate(base.AnchoredRoutingTarget.BackEndServer))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    string key = backEndCookie.Values.GetKey(i);
                    backEndCookie.Values.Remove(key);
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; Removed cookie entry with key {1}.", base.TraceContext, key);
                    }
                }
                else
                {
                    num++;
                    if (backEndCookieEntryBase.ExpiryTime > exDateTime)
                    {
                        exDateTime = backEndCookieEntryBase.ExpiryTime;
                    }
                }
            }
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; {1}", base.TraceContext, (num == 0) ? "Marking current cookie as expired." : "Extending cookie expiration.");
            }
            backEndCookie.Expires = exDateTime.UniversalTime;
        }
示例#3
0
        // Token: 0x060000CC RID: 204 RVA: 0x00005010 File Offset: 0x00003210
        public virtual BackEndServer AcceptBackEndCookie(HttpCookie backEndCookie)
        {
            if (backEndCookie == null)
            {
                throw new ArgumentNullException("backEndCookie");
            }
            string        name          = this.ToCookieKey();
            string        text          = backEndCookie.Values[name];
            BackEndServer backEndServer = null;

            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    BackEndCookieEntryBase backEndCookieEntryBase;
                    string text2;
                    if (!BackEndCookieEntryParser.TryParse(text, out backEndCookieEntryBase, out text2))
                    {
                        throw new InvalidBackEndCookieException();
                    }
                    if (backEndCookieEntryBase.Expired)
                    {
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                        {
                            ExTraceGlobals.VerboseTracer.TraceDebug <BackEndCookieEntryBase>((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Back end cookie entry {0} has expired.", backEndCookieEntryBase);
                        }
                        this.RequestContext.Logger.SafeSet(4, string.Format("Expired~{0}", text2));
                        throw new InvalidBackEndCookieException();
                    }
                    this.RequestContext.Logger.SafeSet(4, text2);
                    this.IncomingCookieEntry = backEndCookieEntryBase;
                    this.CacheEntryCacheHit  = true;
                    PerfCounters.HttpProxyCacheCountersInstance.CookieUseRate.Increment();
                    PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageCookieUseRate);
                    backEndServer = this.TryGetBackEndFromCookie(this.IncomingCookieEntry);
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <BackEndServer, BackEndCookieEntryBase>((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Back end server {0} resolved from cookie {1}.", backEndServer, this.IncomingCookieEntry);
                    }
                }
                catch (InvalidBackEndCookieException)
                {
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Invalid back end cookie entry.");
                    }
                    backEndCookie.Values.Remove(name);
                }
            }
            return(backEndServer);
        }
        // Token: 0x06000281 RID: 641 RVA: 0x0000CE08 File Offset: 0x0000B008
        public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry)
        {
            string text = null;

            return(BackEndCookieEntryParser.TryParse(entryValue, out cookieEntry, out text));
        }