public async Task<object> Call(IHttpHandler httpHandler, string baseUrl, Dictionary<string, object> arguments, HttpApiInstrumenter apiInstrumenter = null) { var request = new HttpApiRequest { Url = Url.CreateUrl(baseUrl), Method = Method, Headers = Headers.ToList() }; Action<Func<IHttpArgumentHandler, string, object, Task>> applyArguments = async applier => { foreach (var item in ArgumentHandlers) { var name = item.Key; object argument; if (arguments.TryGetValue(name, out argument)) { var handler = item.Value; await applier(handler, name, argument); } } }; applyArguments(async (handler, name, argument) => await handler.ApplyArgument(request, name, argument)); Func<HttpApiRequest, Task<HttpApiResponse>> call = async apiRequest => await httpHandler.Call(apiRequest); HttpApiResponse response; if (apiInstrumenter != null) response = await apiInstrumenter(request, call); else response = await call(request); applyArguments(async (handler, name, argument) => await handler.ApplyArgument(response, name, argument)); return await ResponseHandler.HandleResponse(request, response); }
public void ReleaseHandler(IHttpHandler httphandler) { if (httphandler is HandlerWrapper) { ((HandlerWrapper) httphandler).ReleaseWrappedHandler(); } }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new SecurityRouteHttpHandler(); return _httpHandler; }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new AssetManagerRouteHttpHandler(_url); return _httpHandler; }
protected override void VerifyAndProcessRequest(IHttpHandler handler, HttpContextBase context) { Precondition.Require(handler, () => Error.ArgumentNull("handler")); Precondition.Require(context, () => Error.ArgumentNull("context")); handler.ProcessRequest(context.Unwrap()); }
public override void ReleaseHandler(IHttpHandler handler) { if (!(handler is SourceViewer)) { base.ReleaseHandler(handler); } }
static HttpHandlerFactory() { DefaultHttpHandler = new StaticFileHttpHandler(); DirectoryHttpHandler = AspNetHandler = new AspNetHttpHandler(); var cache = new Dictionary<string, IHttpHandler>(); handlers = new Dictionary<string, IHttpHandler>(); foreach (HttpHandlerElement handlerElement in ServerConfiguration.HttpHandlers) { try { if (handlerElement.Extension == "*") { DefaultHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache); continue; } if (handlerElement.Extension == "/") { DirectoryHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache); continue; } if (!handlers.ContainsKey(handlerElement.Extension)) { handlers[handlerElement.Extension] = GetOrCreateHttpHandler(handlerElement.HandlerType, cache); } } catch (Exception ex) { log.ErrorFormat("Can not create HttpHandler '{0}'.\r\n{1}", handlerElement.HandlerType, ex); } } }
public void ReleaseHandler(IHttpHandler handler) { if (handler.IsReusable) { pool.Add((RecylingHandler)handler); } }
// synchronous code protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) { if (httpHandler == null) { throw new ArgumentNullException("httpHandler"); } httpHandler.ProcessRequest(HttpContext.Current); }
public TestHttpServer(FixedPortAddress address, IHttpHandler handler) { Url = address.Url; this.handler = handler; Instance = this; }
private static void RegisterUserControl(IHttpHandler handler) { var page = handler as Page; Action<Control> RegisterUserControl = null; Action<ControlCollection> RegisterControls = null; EventHandler onPageLoad = null; onPageLoad = (sender, e) => { RegisterControls = controls => { foreach (Control c in controls) RegisterUserControl(c); }; RegisterUserControl = control => { var userControl = control as UserControl; if (userControl != null) Kernel.Compose(userControl); RegisterControls(control.Controls); }; RegisterControls(page.Controls); page.Load -= onPageLoad; }; if (page != null) page.Load += onPageLoad; }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new ApplicationRouteHttpHandler(_url, _assembly); return _httpHandler; }
public HttpServer(IHttpHandler app, HttpServerSettings settings) { if (app == null) throw new ArgumentNullException("app"); if (settings == null) throw new ArgumentNullException("settings"); // init asp.net host if (settings.AspNetHost) { var appHost = new AppHost(settings); appHost.Init(); } IHttpListener listener; switch (settings.Mode) { case HttpServerMode.TcpListener: listener = new TcpListenerImpl(app, settings); break; case HttpServerMode.HttpListener: listener = new HttpListenerImpl(app, settings); break; default: throw new ArgumentOutOfRangeException(); } _listener = listener; _listener.Start(); _listenerThread = new Thread(Listen); _listenerThread.Start(); }
internal override bool Initialize() { this.serverType = (DocumentationServerType) base.GetFromCache(typeof(DocumentationServerProtocol), base.Type); if (this.serverType == null) { lock (ServerProtocol.InternalSyncObject) { this.serverType = (DocumentationServerType) base.GetFromCache(typeof(DocumentationServerProtocol), base.Type); if (this.serverType == null) { string uri = Uri.EscapeUriString(base.Request.Url.ToString()).Replace("#", "%23"); this.serverType = new DocumentationServerType(base.Type, uri); base.AddToCache(typeof(DocumentationServerProtocol), base.Type, this.serverType); } } } WebServicesSection current = WebServicesSection.Current; if ((current.WsdlHelpGenerator.Href != null) && (current.WsdlHelpGenerator.Href.Length > 0)) { TraceMethod caller = Tracing.On ? new TraceMethod(this, "Initialize", new object[0]) : null; if (Tracing.On) { Tracing.Enter("ASP.NET", caller, new TraceMethod(typeof(PageParser), "GetCompiledPageInstance", new object[] { current.WsdlHelpGenerator.HelpGeneratorVirtualPath, current.WsdlHelpGenerator.HelpGeneratorPath, base.Context })); } this.handler = this.GetCompiledPageInstance(current.WsdlHelpGenerator.HelpGeneratorVirtualPath, current.WsdlHelpGenerator.HelpGeneratorPath, base.Context); if (Tracing.On) { Tracing.Exit("ASP.NET", caller); } } return true; }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new ConfigurationRouteHttpHandler(); return _httpHandler; }
public virtual string ExecuteHandler(IHttpHandler handler) { var writer = new StringWriter(); HttpContext.Current.Server.Execute(handler, writer, true); writer.Flush(); return writer.GetStringBuilder().ToString(); }
public void ReleaseHandler(IHttpHandler handler) { IDisposable d = handler as IDisposable; if (d != null) d.Dispose(); }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new RestServiceRouteHttpHandler(_type, _url); return _httpHandler; }
public HttpListenerImpl(IHttpHandler app, HttpServerSettings settings) { _app = app; _settings = settings; _listener = new HttpListener(); _listener.Prefixes.Add(string.Format(@"http://+:{0}/", settings.Port)); }
internal static void SetUpSessionState(HttpContextBase context, IHttpHandler handler, ConcurrentDictionary<Type, SessionStateBehavior?> cache) { WebPageHttpHandler webPageHandler = handler as WebPageHttpHandler; Debug.Assert(handler != null); SessionStateBehavior? sessionState = GetSessionStateBehavior(webPageHandler.RequestedPage, cache); if (sessionState != null) { // If the page explicitly specifies a session state value, return since it has the most priority. context.SetSessionStateBehavior(sessionState.Value); return; } WebPageRenderingBase page = webPageHandler.StartPage; StartPage startPage = null; do { // Drill down _AppStart and _PageStart. startPage = page as StartPage; if (startPage != null) { sessionState = GetSessionStateBehavior(page, cache); page = startPage.ChildPage; } } while (startPage != null); if (sessionState != null) { context.SetSessionStateBehavior(sessionState.Value); } }
public void ReleaseHandler(IHttpHandler handler) { if (!this._handler.IsReusable) { this._handler = null; } }
public DjangoEngine(IHttpHandler handler) { NDjango.FiltersCS.FilterManager.Instance.Initialize(); NDjango.Template.Manager.RegisterLoader(this); manager = NDjango.Template.Manager.RegisterTag("url", new BistroUrlTag(HttpRuntime.AppDomainAppVirtualPath)); rootDir = HttpRuntime.AppDomainAppPath; }
public void ReleaseHandler(IHttpHandler handler) { var disp = handler as IDisposable; if (disp == null) return; disp.Dispose(); }
public void ReleaseHandler(IHttpHandler httphandler) { //Check whether the handler was created by an internal factory if (httphandler is HandlerWrapper) { ((HandlerWrapper)(httphandler)).ReleaseWrappedHandler(); } }
public void ReleaseHandler(IHttpHandler handler) { if (this._webServicesFactory != null) { ((IHttpHandlerFactory) this._webServicesFactory).ReleaseHandler(handler); this._webServicesFactory = null; } }
/// <summary>Inject the current page into the page handler.</summary> /// <param name="handler">The handler executing the request.</param> public virtual void InjectCurrentPage(PathData path, IHttpHandler handler) { IContentTemplate template = handler as IContentTemplate; if (template != null && path != null) { template.CurrentItem = path.CurrentPage; } }
protected JuniorRouteApplicationConfiguration SetHandler(IHttpHandler handler) { handler.ThrowIfNull("handler"); Handler = handler; return this; }
public static IHttpHandler Create(IHttpHandler httpHandler, IHttpHandlerFactory factory) { if (httpHandler is IHttpAsyncHandler) { return new AsyncHandlerWrapper((IHttpAsyncHandler) httpHandler, factory); } return new XamlHttpHandlerFactory.HandlerWrapper(httpHandler, factory); }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { if (this.handler == null) { this.handler = new ServiceHttpHandler(); } return this.handler; }
static StaticRoute() { if (staticFileHandler == null) { Type type = Type.GetType("System.Web.StaticFileHandler"); staticFileHandler = Activator.CreateInstance(type) as IHttpHandler; } }
public override void Execute(IHttpHandler handler, TextWriter writer, bool preserveForm) { w.Execute(handler, writer, preserveForm); }
public EasyHttpServer(IOptions <HttpServerOptions> options, ILogger <EasyHttpServer> logger, IHttpHandler httpHandler) { this.httpHandler = httpHandler; this.options = options.Value; this.logger = logger; serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var endpoint = new IPEndPoint(IPAddress.Parse(this.options.Address), this.options.Port); serverSocket.Bind(endpoint); }
public void ReleaseHandler(IHttpHandler handler) { }
/// <summary> /// Constructor /// </summary> /// <param name="httpHandler">HttpHandler</param> public PushManager(IHttpHandler httpHandler) { this.httpHandler = httpHandler; }
static HttpHandlerFactory() { //MONO doesn't implement this property var pi = typeof(HttpRuntime).GetProperty("UsingIntegratedPipeline"); if (pi != null) { IsIntegratedPipeline = (bool)pi.GetGetMethod().Invoke(null, new object[0]); } var appHost = HostContext.AppHost; var config = appHost.Config; var isAspNetHost = HostContext.IsAspNetHost; WebHostPhysicalPath = appHost.VirtualPathProvider.RootDirectory.RealPath; HostAutoRedirectsDirs = isAspNetHost && !Env.IsMono; //Apache+mod_mono treats path="servicestack*" as path="*" so takes over root path, so we need to serve matching resources var hostedAtRootPath = config.HandlerFactoryPath == null; //DefaultHttpHandler not supported in IntegratedPipeline mode if (!IsIntegratedPipeline && isAspNetHost && !hostedAtRootPath && !Env.IsMono) { DefaultHttpHandler = new DefaultHttpHandler(); } foreach (var file in appHost.VirtualPathProvider.GetRootFiles()) { var fileNameLower = file.Name.ToLower(); if (DefaultRootFileName == null && config.DefaultDocuments.Contains(fileNameLower)) { //Can't serve Default.aspx pages so ignore and allow for next default document if (!fileNameLower.EndsWith(".aspx")) { DefaultRootFileName = fileNameLower; ((StaticFileHandler)StaticFileHandler).SetDefaultFile(file.VirtualPath, file.ReadAllBytes(), file.LastModified); if (DefaultHttpHandler == null) { DefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = DefaultRootFileName } } ; } } WebHostRootFileNames.Add(file.Name.ToLower()); } foreach (var dir in appHost.VirtualPathProvider.GetRootDirectories()) { WebHostRootFileNames.Add(dir.Name.ToLower()); } if (!string.IsNullOrEmpty(config.DefaultRedirectPath)) { DefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.DefaultRedirectPath } } ; if (DefaultHttpHandler == null && !string.IsNullOrEmpty(config.MetadataRedirectPath)) { DefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.MetadataRedirectPath } } ; if (!string.IsNullOrEmpty(config.MetadataRedirectPath)) { NonRootModeDefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.MetadataRedirectPath } } ; if (DefaultHttpHandler == null) { DefaultHttpHandler = NotFoundHttpHandler; } var defaultRedirectHanlder = DefaultHttpHandler as RedirectHttpHandler; var debugDefaultHandler = defaultRedirectHanlder != null ? defaultRedirectHanlder.RelativeUrl : typeof(DefaultHttpHandler).GetOperationName(); SetApplicationBaseUrl(config.WebHostUrl); ForbiddenHttpHandler = appHost.GetCustomErrorHttpHandler(HttpStatusCode.Forbidden); if (ForbiddenHttpHandler == null) { ForbiddenHttpHandler = new ForbiddenHttpHandler { IsIntegratedPipeline = IsIntegratedPipeline, WebHostPhysicalPath = WebHostPhysicalPath, WebHostRootFileNames = WebHostRootFileNames, WebHostUrl = config.WebHostUrl, DefaultRootFileName = DefaultRootFileName, DefaultHandler = debugDefaultHandler, }; } NotFoundHttpHandler = appHost.GetCustomErrorHttpHandler(HttpStatusCode.NotFound); if (NotFoundHttpHandler == null) { NotFoundHttpHandler = new NotFoundHttpHandler { IsIntegratedPipeline = IsIntegratedPipeline, WebHostPhysicalPath = WebHostPhysicalPath, WebHostRootFileNames = WebHostRootFileNames, WebHostUrl = config.WebHostUrl, DefaultRootFileName = DefaultRootFileName, DefaultHandler = debugDefaultHandler, }; } }
public SecurityEditUserVM(IHttpHandler handler) : base(handler) { PageTitle = "Photon Server Edit User Security"; }
/// <summary> /// Eos Client api constructor. /// </summary> /// <param name="config">Configures client parameters</param> /// <param name="httpHandler">Http handler implementation</param> public EosApi(EosConfigurator config, IHttpHandler httpHandler) { Config = config; HttpHandler = httpHandler; }
private HandlerWrapper(IHttpHandler httpHandler, IHttpHandlerFactory factory) { this.httpHandler = httpHandler; this.factory = factory; }
public AuthFacade(IConfiguration config, IHttpHandler handler) { _config = config; _handler = handler; }
public ServerExecuteHttpHandlerWrapper(IHttpHandler httpHandler) { _httpHandler = httpHandler; }
public static IHttpHandler WrapForServerExecute(IHttpHandler httpHandler) { IHttpAsyncHandler asyncHandler = httpHandler as IHttpAsyncHandler; return((asyncHandler != null) ? new ServerExecuteHttpHandlerAsyncWrapper(asyncHandler) : new ServerExecuteHttpHandlerWrapper(httpHandler)); }
static void Process(HttpWorkerRequest req) { #if TARGET_J2EE HttpContext context = HttpContext.Current; if (context == null) { context = new HttpContext(req); } else { context.SetWorkerRequest(req); } #else HttpContext context = new HttpContext(req); #endif HttpContext.Current = context; bool error = false; #if !TARGET_J2EE if (firstRun) { #if NET_2_0 SetupOfflineWatch(); #endif firstRun = false; if (initialException != null) { FinishWithException(req, new HttpException("Initial exception", initialException)); error = true; } } #if NET_2_0 if (AppIsOffline(context)) { return; } #endif #endif // // Get application instance (create or reuse an instance of the correct class) // HttpApplication app = null; if (!error) { try { app = HttpApplicationFactory.GetApplication(context); } catch (Exception e) { FinishWithException(req, new HttpException("", e)); error = true; } } if (error) { context.Request.ReleaseResources(); context.Response.ReleaseResources(); HttpContext.Current = null; } else { context.ApplicationInstance = app; // // Ask application to service the request // #if TARGET_J2EE IHttpAsyncHandler ihah = app; if (context.Handler == null) { ihah.BeginProcessRequest(context, new AsyncCallback(request_processed), context); } else { app.Tick(); } //ihh.ProcessRequest (context); IHttpExtendedHandler extHandler = context.Handler as IHttpExtendedHandler; if (extHandler != null && !extHandler.IsCompleted) { return; } if (context.Error is UnifyRequestException) { return; } ihah.EndProcessRequest(null); #else IHttpHandler ihh = app; // IAsyncResult appiar = ihah.BeginProcessRequest (context, new AsyncCallback (request_processed), context); // ihah.EndProcessRequest (appiar); ihh.ProcessRequest(context); #endif HttpApplicationFactory.Recycle(app); } }
void IHttpHandlerFactory.ReleaseHandler(IHttpHandler handler) { }
public TokenManager(ILoginConfig config, ILoginCredentials credentials, IResponseManager responseManager, IValidationManager validationManager, IOauthTokenFactory tokenFactory, IHttpHandler client) { this.config = config; this.credentials = credentials; this.responseManager = responseManager; this.validationManager = validationManager; this.tokenFactory = tokenFactory; this.client = client; }
/// <summary> /// Unregisters a handler from the provider /// </summary> /// <param name="handler">The handler to unregister</param> public abstract void Unregister(IHttpHandler handler);
protected virtual ISiteMapNode FindSiteMapNodeFromUrl(string relativeUrl, string relativePath, string hostName, IHttpHandler handler) { ISiteMapNode node = null; // Try absolute match with querystring var absoluteMatch = this.siteMapChildStateFactory.CreateUrlKey(relativeUrl, hostName); node = this.FindSiteMapNodeFromUrlMatch(absoluteMatch); // Try absolute match without querystring if (node == null && !string.IsNullOrEmpty(relativePath)) { var absoluteMatchWithoutQueryString = this.siteMapChildStateFactory.CreateUrlKey(relativePath, hostName); node = this.FindSiteMapNodeFromUrlMatch(absoluteMatchWithoutQueryString); } // Try relative match if (node == null) { var relativeMatch = this.siteMapChildStateFactory.CreateUrlKey(relativeUrl, string.Empty); node = this.FindSiteMapNodeFromUrlMatch(relativeMatch); } // Try relative match with ASP.NET handler querystring if (node == null) { Page currentHandler = handler as Page; if (currentHandler != null) { string clientQueryString = currentHandler.ClientQueryString; if (clientQueryString.Length > 0) { var aspNetRelativeMatch = this.siteMapChildStateFactory.CreateUrlKey(relativePath + "?" + clientQueryString, string.Empty); node = this.FindSiteMapNodeFromUrlMatch(aspNetRelativeMatch); } } } // Try relative match without querystring if (node == null && !string.IsNullOrEmpty(relativePath)) { var relativeMatchWithoutQueryString = this.siteMapChildStateFactory.CreateUrlKey(relativePath, string.Empty); node = this.FindSiteMapNodeFromUrlMatch(relativeMatchWithoutQueryString); } return(node); }
/// <summary> /// 调用处理方法 /// </summary> /// <param name="context"></param> private async Task InvokeHandler(HttpListenerContext context) { context.Response.StatusCode = 404; MethodInfo methodInfo = null; IHttpHandler httpHandler = null; string postbody = ""; switch (context.Request.HttpMethod) { case "GET": this.getHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo); if (methodInfo != null) { this.handlersMapping.TryGetValue(methodInfo, out httpHandler); } break; case "POST": this.postHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo); if (methodInfo != null) { this.handlersMapping.TryGetValue(methodInfo, out httpHandler); using (StreamReader sr = new StreamReader(context.Request.InputStream)) { postbody = sr.ReadToEnd(); } } break; default: context.Response.StatusCode = 405; break; } if (httpHandler != null) { object[] args = InjectParameters(context, methodInfo, postbody); // 自动把返回值,以json方式响应。 object resp = methodInfo.Invoke(httpHandler, args); object result = resp; if (resp is Task t) { await t; result = t.GetType().GetProperty("Result").GetValue(t, null); } if (result != null) { using (StreamWriter sw = new StreamWriter(context.Response.OutputStream)) { if (result.GetType() == typeof(string)) { sw.Write(result.ToString()); } else { sw.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); } } } } }
public ControllerRouter(IDependencyContainer dependencyContainer) { this.dependencyContainer = dependencyContainer; this.resourceHandler = new ResourceRouter(); }
public LoginWindow(IHttpHandler httpHandler, string webAppBaseUrl) { _httpHandler = httpHandler; _webAppBaseUrl = webAppBaseUrl; }
public HttpSyncHandlerWrapper(IHttpHandler handler) { _handler = handler; }
protected virtual bool TryCreateHandler(OrganizationServiceContext context, string logicalName, Guid id, out IHttpHandler handler) { if (string.Equals(logicalName, "annotation", StringComparison.InvariantCulture)) { var entity = context.CreateQuery(logicalName).FirstOrDefault(e => e.GetAttributeValue <Guid>("annotationid") == id); if (entity != null) { handler = CreateAnnotationHandler(entity); return(true); } } handler = null; return(false); }
public void ProcessRequest(HttpContext context) { Provider.OnBeginRequest(); string path = context.Request.Url.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped); if (path[path.Length - 1] == '/') { path = path.Substring(0, path.LastIndexOf('/')); } string fileName = path.Substring(path.LastIndexOf('/') + 1); if (fileName.ToLower().Contains(".aspx")) { Provider.Response.Redirect(Provider.Configuration.MainPage, true); return; } fileName = fileName.Substring(0, fileName.LastIndexOf('.')); if (fileName.Contains(".")) // bu demektir ki cinar.cms.js gibi bir dosya isteniyor { if (fileName.EndsWith(".css")) { context.Response.ContentType = "text/css"; } else if (fileName.EndsWith(".js")) { context.Response.ContentType = "text/javascript"; } /* * HttpCachePolicy c = context.Response.Cache; * c.SetCacheability(HttpCacheability.Public); * c.SetMaxAge(new TimeSpan(1, 0, 0)); */ if (context.Request.Url.IsLoopback) { string resourceFilePath = Path.Combine(Provider.AppSettings["pathToLocalResources"], fileName); //string resourceFilePath = Provider.MapPath("/").Replace("Cinar.CMS.Web", "Cinar.CMS.Library") + "Resources\\" + fileName; if (!File.Exists(resourceFilePath)) { resourceFilePath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Provider.MapPath("/")))) + "\\Cinar\\Cinar.CMS.Library\\Resources\\" + fileName; } if (File.Exists(resourceFilePath)) { context.Response.Write(File.ReadAllText(resourceFilePath)); } } else { string s = Properties.Resources.ResourceManager.GetString(fileName.Replace(".", "_")); context.Response.Write(s ?? ("There is no resource with this name: " + fileName.Replace(".", "_"))); } return; } switch (fileName) { case "ModuleInfo": new ModuleInfo().ProcessRequest(context); break; case "EntityInfo": new EntityInfo().ProcessRequest(context); break; case "SystemInfo": new SystemInfo().ProcessRequest(context); break; case "Admin": new Admin().ProcessRequest(context); break; case "Social": new Social().ProcessRequest(context); break; case "VirtualPOSBankAsya": new VirtualPOSBankAsya().ProcessRequest(context); break; case "RunModuleMethod": case "DoLogin": case "SaveMember": case "LoginWithKeyword": case "UserActivation": case "ValidateNewEmail": case "RSS": case "Print": case "Redirect": case "AdClick": case "UploadContent": case "UploadContentTest": case "DefaultStyleSheet": case "DefaultJavascript": case "UpdateTags": case "GetAllActivity": case "AutoCompleteTag": case "LikeIt": case "Subscribe": case "GetModuleHtml": case "KeepSession": case "EditImageCrop": case "EditImageRotate": case "EditImageResize": case "EditImageReset": case "getLocation": case "FacebookLogin": case "reportBug": case "socialAuthLogin": case "loginBySocialAuth": case "getSocialFriends": case "logout_sauth": case "login_sauth": case "validate_sauth": case "isNickAvailable": case "parseWebPageHtmlAsContent": new DoCommand().ProcessRequest(context); break; case "DoCommand": new DoCommand().ProcessRequest(context); break; case "Console": new Console().ProcessRequest(context); break; default: Type type = Provider.GetType("Handlers", fileName); if (type != null) { IHttpHandler handler = (IHttpHandler)Activator.CreateInstance(type); handler.ProcessRequest(context); } else { HttpContext.Current.Response.Write("Handler not found: " + fileName + " (URL: " + fileName + ".ashx)"); } break; } }
/// <summary> /// IHttpHandlerFactory must override method /// </summary> /// <param name="handler"></param> public virtual void ReleaseHandler(IHttpHandler handler) { }
internal static void Init() { try { var isIntegratedPipeline = false; #if !NETSTANDARD2_0 //MONO doesn't implement this property var pi = typeof(HttpRuntime).GetProperty("UsingIntegratedPipeline"); if (pi != null) { isIntegratedPipeline = (bool)pi.GetGetMethod().Invoke(null, TypeConstants.EmptyObjectArray); } #endif var appHost = HostContext.AppHost; var config = appHost.Config; var isAspNetHost = HostContext.IsAspNetHost; WebHostPhysicalPath = appHost.VirtualFileSources.RootDirectory.RealPath; //Apache+mod_mono treats path="servicestack*" as path="*" so takes over root path, so we need to serve matching resources var hostedAtRootPath = config.HandlerFactoryPath == null; //DefaultHttpHandler not supported in IntegratedPipeline mode if (!isIntegratedPipeline && isAspNetHost && !hostedAtRootPath && !Env.IsMono) { DefaultHttpHandler = new DefaultHttpHandler(); } var rootFiles = appHost.VirtualFileSources.GetRootFiles().ToList(); foreach (var file in rootFiles) { var fileNameLower = file.Name.ToLowerInvariant(); if (DefaultRootFileName == null && config.DefaultDocuments.Contains(fileNameLower)) { //Can't serve Default.aspx pages so ignore and allow for next default document if (!fileNameLower.EndsWith(".aspx")) { DefaultRootFileName = fileNameLower; StaticFileHandler.SetDefaultFile(file.VirtualPath, file.ReadAllBytes(), file.LastModified); if (DefaultHttpHandler == null) { DefaultHttpHandler = new StaticFileHandler(file); } } } } if (!string.IsNullOrEmpty(config.DefaultRedirectPath)) { DefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.DefaultRedirectPath }; NonRootModeDefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.DefaultRedirectPath }; } if (DefaultHttpHandler == null && !string.IsNullOrEmpty(config.MetadataRedirectPath)) { DefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.MetadataRedirectPath }; NonRootModeDefaultHttpHandler = new RedirectHttpHandler { RelativeUrl = config.MetadataRedirectPath }; } if (DefaultHttpHandler == null) { DefaultHttpHandler = NotFoundHttpHandler; } var debugDefaultHandler = DefaultHttpHandler is RedirectHttpHandler defaultRedirectHanlder ? defaultRedirectHanlder.RelativeUrl : typeof(DefaultHttpHandler).GetOperationName(); ForbiddenHttpHandler = appHost.GetCustomErrorHttpHandler(HttpStatusCode.Forbidden); if (ForbiddenHttpHandler == null) { ForbiddenHttpHandler = new ForbiddenHttpHandler { WebHostPhysicalPath = WebHostPhysicalPath, WebHostUrl = config.WebHostUrl, DefaultRootFileName = DefaultRootFileName, DefaultHandler = debugDefaultHandler, }; } NotFoundHttpHandler = appHost.GetCustomErrorHttpHandler(HttpStatusCode.NotFound); if (NotFoundHttpHandler == null) { NotFoundHttpHandler = new NotFoundHttpHandler { WebHostPhysicalPath = WebHostPhysicalPath, WebHostUrl = config.WebHostUrl, DefaultRootFileName = DefaultRootFileName, DefaultHandler = debugDefaultHandler, }; } } catch (Exception ex) { HostContext.AppHost.OnStartupException(ex); } }
public MyRouteHandler(IHttpHandler handler) { this.handler = handler; }
protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) { throw new ApplicationException("MyUrlRoutingHandler"); }
public void ReleaseHandler(IHttpHandler handler) { IHttpHandlerFactory pageFactory = CreatePageFactory(); pageFactory.ReleaseHandler(handler); }
public override void Transfer(IHttpHandler handler, bool preserveForm) { w.Transfer(handler, preserveForm); }
internal static void SetUpSessionState(HttpContextBase context, IHttpHandler handler) { SetUpSessionState(context, handler, _sessionStateBehaviorCache); }
public SwapiService(ILogger <SwapiService> logger, ISwapiRepository repository, IHttpHandler httpHandler) { _logger = logger; _httpHandler = httpHandler; _repository = repository; }