public HttpRequest(IHttpUserLookup userLookup, IOwinRequest request, HttpContextSettings settings) { this.request = request; this.settings = settings; this.userLookup = userLookup; this.currentUser = new OneTryLazy <IHttpUser>(() => new HttpUser(HttpUser.NullUserName)); }
public static IResult ProcessRequest( this IOwinContext context, ControllerExecutionManager manager, IHttpUserLookup instance, string salt, ILogger logger) { var httpContext = new HttpContext( manager.Application, logger, instance, context, new HttpContextSettings { ApplicationSaltSettings = salt }); CurrentHttpContextProvider.ThreadSpecificHttpContext = httpContext; httpContext.Unpack(); logger.Log( string.Format("{0} {1}: {2}", context.Request.Scheme, context.Request.Method, context.Request.Path), LogLevels.ApplicationInfo); IResult result; try { result = manager.ExecuteController(httpContext); } catch (Exception e) { // var st = new System.Diagnostics.StackTrace(e, true); // string text = string.Concat(e.Message, st); logger.Log(e.ToString(), LogLevels.ApplicationError); if (httpContext.ApplicationInstance.Mode == ApplicationMode.Prod) { throw; } result = new ResponseResult(httpContext.Response, new SimpleContent { BodyContent = e.ToString(), ContentType = "text/plain" }); } httpContext.Pack(); CurrentHttpContextProvider.ThreadSpecificHttpContext = null; return(result); }
public HttpContext( IApplication application, ILogger logger, IHttpUserLookup userLookup, IOwinContext context, HttpContextSettings settings) { application.Validate().IsNotNull(); logger.Validate().IsNotNull(); context.Validate().IsNotNull(); settings.Validate().IsNotNull(); this.application = application; this.logger = logger; this.userLookup = userLookup; this.context = context; this.settings = settings; this.httpSession = new HttpSession(this.context); this.httpFlash = new HttpFlash(this.context); this.httpRequest = new HttpRequest(this.userLookup, this.context.Request, this.settings); this.httpResponse = new HttpResponse(this.context.Response, this.settings); this.cookieJar = new RetryLazy <SecureCookieJarBase <KeyValuePair <string, string> > >(() => new OwinCookieJar(this.context, this.CookieJarSettings())); }