IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            string text = source.Headers["X-PreferServerAffinity"];

            if (!string.IsNullOrEmpty(text) && text.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                HttpCookie httpCookie = source.Cookies["X-BackEndOverrideCookie"];
                string     text2      = (httpCookie == null) ? null : httpCookie.Value;
                if (!string.IsNullOrEmpty(text2))
                {
                    string text3;
                    string s;
                    Utilities.GetTwoSubstrings(text2, '~', out text3, out s);
                    int value;
                    if (!string.IsNullOrWhiteSpace(text3) && int.TryParse(s, out value))
                    {
                        IRoutingKey routingKey = new ServerRoutingKey(text3, new int?(value));
                        diagnostics.AddRoutingkey(routingKey, "X-BackEndOverrideCookie");
                        return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                        {
                            routingKey
                        }));
                    }
                    diagnostics.AddErrorInfo("Unable to parse TargetServer:" + text2);
                }
            }
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Example #2
0
 internal void OnPostAuthorizeRequest(HttpContextBase context)
 {
     Diagnostics.SendWatsonReportOnUnhandledException(delegate()
     {
         if (!this.isEnabled)
         {
             return;
         }
         IAddressFinderDiagnostics addressFinderDiagnostics = this.GetDiagnostics(context);
         IAddressFinder addressFinder = this.addressFinderFactory.CreateAddressFinder(HttpProxyGlobals.ProtocolType, context.Request.Url.AbsolutePath);
         if (addressFinder != null)
         {
             AddressFinderSource source   = new AddressFinderSource(context.Items, context.Request.Headers, context.Request.QueryString, context.Request.Url, context.Request.ApplicationPath, context.Request.FilePath, context.Request.Cookies);
             IRoutingKey[] value          = addressFinder.Find(source, addressFinderDiagnostics);
             context.Items["RoutingKeys"] = value;
         }
         else
         {
             ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, ProtocolType>((long)this.GetHashCode(), "[AddressFinderModule::OnPostAuthorizeRequest]: addressFinder is null: Method {0}; Url {1}; Protocol {2};", context.Request.HttpMethod, context.Request.Url, HttpProxyGlobals.ProtocolType);
             addressFinderDiagnostics.AddErrorInfo("addressFinder is null");
         }
         addressFinderDiagnostics.LogRoutingKeys();
     }, new Diagnostics.LastChanceExceptionHandler(this.LastChanceExceptionHandler));
 }