Revenj.Http.HttpSocketContext.ForRouteWithAuth C# (CSharp) Method

ForRouteWithAuth() private method

private ForRouteWithAuth ( RouteMatch route, IPrincipal principal ) : void
route RouteMatch
principal IPrincipal
return void
        internal void ForRouteWithAuth(RouteMatch route, IPrincipal principal)
        {
            this.Route = route;
            this.Principal = principal;
        }

Usage Example

Example #1
0
        private void ProcessAllMessages(RequestInfo request, HttpSocketContext ctx, IPrincipal principal, ManualResetEvent resetEvent, bool canReschedule)
        {
            RouteMatch?  routeMatch;
            RouteHandler route;
            var          socket = request.Socket;

            while (ctx.Parse(socket, out routeMatch, out route))
            {
                var match = routeMatch.Value;
                var auth  = Authentication.TryAuthorize(ctx.GetRequestHeader("authorization"), ctx.RawUrl, route);
                if (auth.Principal != null)
                {
                    if (canReschedule && route.IsAsync)
                    {
                        resetEvent.Reset();
                        ThreadPool.QueueUserWorkItem(ProcessInThread, new ThreadArgs(request, ctx, resetEvent, auth, route, match));
                        Thread.Yield();
                        resetEvent.WaitOne();
                        return;
                    }
                    else
                    {
                        ctx.ForRouteWithAuth(match, auth.Principal);
                        if (principal != auth.Principal)
                        {
                            Thread.CurrentPrincipal = principal = auth.Principal;
                        }
                        using (var stream = route.Handle(match.OrderedArgs, ctx, ctx, ctx.InputStream, ctx.OutputStream))
                        {
                            var keepAlive = ctx.Return(stream, socket, !canReschedule);
                            if (keepAlive)
                            {
                                if (ctx.Pipeline)
                                {
                                    continue;
                                }
                                else if (socket.Connected && Requests.TryAdd(request.Processed()))
                                {
                                    return;
                                }
                            }
                            socket.Close();
                            return;
                        }
                    }
                }
                else
                {
                    CheckAuth(socket, auth, ctx);
                    return;
                }
            }
        }
All Usage Examples Of Revenj.Http.HttpSocketContext::ForRouteWithAuth