/// <summary> /// Adds a handler for a virtual directory /// </summary> /// <param name="hostName">The host name to use for this handler ( currently only "" is supported )</param> /// <param name="virtualPath">The virtual path to respond to requests on</param> /// <param name="contextHandler">The handler that should respond to requests in this path</param> /// <param name="force">True if an existing handler should be replaced by this one</param> public void AddHandlerContext(string hostName, string virtualPath, IAdkHttpHandlerFactory contextHandler, bool force) { fListener.AddHandlerContext(hostName, virtualPath, contextHandler, force); }
/// <summary> /// Adds a handler for a virtual directory /// </summary> /// <param name="hostName">The host name to use for this handler ( currently only "" is supported )</param> /// <param name="virtualPath">The virtual path to respond to requests on</param> /// <param name="contextHandler">The handler that should respond to requests in this path</param> /// <param name="force">True if an existing handler should be replaced by this one</param> public void AddHandlerContext( string hostName, string virtualPath, IAdkHttpHandlerFactory contextHandler, bool force ) { fListener.AddHandlerContext( hostName, virtualPath, contextHandler, force ); }
/// <summary> /// Adds a handler to the list of handlers associated with this listener /// </summary> /// <param name="hostName">The host name to use for request resolution( not currently used )</param> /// <param name="virtualPath">The virtual path e.g. "/virdir1"</param> /// <param name="factory">The object responsible for creating new handlers for requests</param> /// <param name="force">If set to true, the handler will replace any other handlers defined at the path, if false, an exception will /// be thrown if any handlers are already defined at the path</param> public void AddHandlerContext( string hostName, string virtualPath, IAdkHttpHandlerFactory factory, bool force ) { // We don't support virtual hosts in this version. Look up the context by the virtual path only string contextPath = BuildContextString( virtualPath ); if ( fHandlerContexts.Contains( contextPath ) && !force ) { throw new AdkException( "Handler is already defined for " + virtualPath, null ); } fHandlerContexts[contextPath] = factory; }
internal IAdkHttpHandler GetHandlerForContext(AdkHttpRequest request) { IAdkHttpHandlerFactory factory = this.SearchForContextHandler(request.Url); if (factory != null) { return(factory.CreateHandler(request)); } else { return(this.AnonymousHandler); } }
/// <summary> /// Adds a handler to the list of handlers associated with this listener /// </summary> /// <param name="hostName">The host name to use for request resolution( not currently used )</param> /// <param name="virtualPath">The virtual path e.g. "/virdir1"</param> /// <param name="factory">The object responsible for creating new handlers for requests</param> /// <param name="force">If set to true, the handler will replace any other handlers defined at the path, if false, an exception will /// be thrown if any handlers are already defined at the path</param> public void AddHandlerContext(string hostName, string virtualPath, IAdkHttpHandlerFactory factory, bool force) { // We don't support virtual hosts in this version. Look up the context by the virtual path only string contextPath = BuildContextString(virtualPath); if (fHandlerContexts.Contains(contextPath) && !force) { throw new AdkException("Handler is already defined for " + virtualPath, null); } fHandlerContexts[contextPath] = factory; }
public IAdkHttpHandlerFactory SearchForContextHandler(Uri requestUri) { string searchPath = requestUri.AbsolutePath; if (searchPath.IndexOf('.') == -1 && !searchPath.EndsWith("/")) { searchPath = searchPath + "/"; } while (searchPath.Length > 0) { searchPath = searchPath.Substring(0, searchPath.LastIndexOf('/')); IAdkHttpHandlerFactory factory = (IAdkHttpHandlerFactory)fHandlerContexts[searchPath]; if (factory != null) { return(factory); } } return(null); }