private void CreateHost(VPathToHost v)
 {
     lock (v) {
         if (v.AppHost == null)
         {
             v.CreateHost(this, web_source);
             if (HostCreated != null)
             {
                 HostCreated(v.vhost, v.vport,
                             v.vpath, v.AppHost);
             }
         }
     }
 }
예제 #2
0
        public VPathToHost GetApplicationForPath(string vhost, int port, string path,
                                                 bool defaultToRoot)
        {
            if (single_app)
            {
                return((VPathToHost)vpathToHost [0]);
            }

            VPathToHost bestMatch       = null;
            int         bestMatchLength = 0;

            for (int i = vpathToHost.Count - 1; i >= 0; i--)
            {
                VPathToHost v           = (VPathToHost)vpathToHost [i];
                int         matchLength = v.vpath.Length;
                if (matchLength <= bestMatchLength || !v.Match(vhost, port, path))
                {
                    continue;
                }

                bestMatchLength = matchLength;
                bestMatch       = v;
            }

            if (bestMatch != null)
            {
                lock (bestMatch) {
                    if (bestMatch.AppHost == null)
                    {
                        bestMatch.CreateHost(this, webSource);
                    }
                }
                return(bestMatch);
            }

            if (defaultToRoot)
            {
                return(GetApplicationForPath(vhost, port, "/", false));
            }

            if (verbose)
            {
                Console.WriteLine("No application defined for: {0}:{1}{2}", vhost, port, path);
            }

            return(null);
        }
예제 #3
0
        public VPathToHost GetApplicationForPath(string vhost, int port, string path,
                                                 bool defaultToRoot)
        {
            if (SingleApplication)
            {
                return(vpathToHost [0]);
            }

            VPathToHost bestMatch       = null;
            int         bestMatchLength = 0;

            for (int i = vpathToHost.Count - 1; i >= 0; i--)
            {
                var v           = vpathToHost [i];
                int matchLength = v.vpath.Length;
                if (matchLength <= bestMatchLength || !v.Match(vhost, port, path))
                {
                    continue;
                }

                bestMatchLength = matchLength;
                bestMatch       = v;
            }

            if (bestMatch != null)
            {
                lock (bestMatch)
                {
                    if (bestMatch.AppHost == null)
                    {
                        bestMatch.CreateHost(this, webSource);
                    }
                }
                      return(bestMatch);
            }

            if (defaultToRoot)
            {
                return(GetApplicationForPath(vhost, port, "/", false));
            }

            if (Verbose)
                Logger.Write(LogLevel.Error, "No application defined for: {0}:{1}{2}", vhost, port, path); }