Esempio n. 1
0
        /// <summary>
        /// Initiates an asynchronous call to the HTTP handler.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"></see> object that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <param name="cb">The <see cref="T:System.AsyncCallback"></see> to call when the asynchronous method call is complete. If cb is null, the delegate is not called.</param>
        /// <param name="extraData">Any extra data needed to process the request.</param>
        /// <returns>
        /// An <see cref="T:System.IAsyncResult"></see> that contains information about the status of the process.
        /// </returns>
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            Log.Debug(typeof(ProxyHandler), "BeginProcessRequest()");

            // Request URL Format: http://<load-balancer>:<port>/<tenant>/<application>
            Uri requestedUrl = context.Request.Url;

            Log.Debug(typeof(ProxyHandler), "Request: " + requestedUrl);

            ReverseProxyContext rpContext = new ReverseProxyContext();

            rpContext.RequestedHostName     = requestedUrl.Host;
            rpContext.RequestedPort         = requestedUrl.Port;
            rpContext.RequestedPathAndQuery = requestedUrl.PathAndQuery;
            rpContext.TenantName            = findTenantName(rpContext.RequestedPathAndQuery);
            rpContext.ApplicationName       = findApplicationName(rpContext.RequestedPathAndQuery);

            if ((!string.IsNullOrEmpty(rpContext.TenantName)) && (!string.IsNullOrEmpty(rpContext.ApplicationName)))
            {
                rpContext.ApplicationInstance = LoadBalancerControllerWebUtil.GetApplicationInstance(rpContext.TenantName, rpContext.ApplicationName);
                if (rpContext.ApplicationInstance != null)
                {
                    // Asynchronously add request to the load balancer request queue
                    rpContext.AddReqCaller = new ASyncAddRequestToQueue(AddRequestToQueue);
                    addReqResult           = rpContext.AddReqCaller.BeginInvoke(context, rpContext.ApplicationInstance.NodeId,
                                                                                rpContext.ApplicationInstance.ApplicationId,
                                                                                rpContext.ApplicationInstance.Id,
                                                                                rpContext.ApplicationInstance.Tenant.Id, null, null);
                }
            }

            delegate_ = new AsyncProcessorDelegate(ReverseProxyRequest);
            return(delegate_.BeginInvoke(context, rpContext, cb, extraData));
        }
        public bool IsReusable => false; // httpHandler.IsReusable;

        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            if (!context.User.Identity.IsAuthenticated)
            {
                _Delegate = new AsyncProcessorDelegate(ProcessRequest);
                return(_Delegate.BeginInvoke(context, cb, extraData));
            }
            return(httpHandler.BeginProcessRequest(context, cb, extraData));
        }
Esempio n. 3
0
 public virtual IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
 {
     Logging.Write.Info("Async call: BeginProcessRequest(), threadid=" + Thread.CurrentThread.ManagedThreadId);
     _Delegate = new AsyncProcessorDelegate(ProcessRequest);
     return(_Delegate.BeginInvoke(context, cb, extraData));
 }
Esempio n. 4
0
        /// <summary>
        /// Initiates an asynchronous call to the HTTP handler.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"></see> object that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <param name="cb">The <see cref="T:System.AsyncCallback"></see> to call when the asynchronous method call is complete. If cb is null, the delegate is not called.</param>
        /// <param name="extraData">Any extra data needed to process the request.</param>
        /// <returns>
        /// An <see cref="T:System.IAsyncResult"></see> that contains information about the status of the process.
        /// </returns>
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            Log.Debug(typeof(ProxyHandler), "BeginProcessRequest()");

            // Request URL Format: http://<load-balancer>:<port>/<tenant>/<application>
            Uri requestedUrl = context.Request.Url;
            Log.Debug(typeof(ProxyHandler), "Request: " + requestedUrl);

            ReverseProxyContext rpContext = new ReverseProxyContext();
            rpContext.RequestedHostName = requestedUrl.Host;
            rpContext.RequestedPort = requestedUrl.Port;
            rpContext.RequestedPathAndQuery = requestedUrl.PathAndQuery;
            rpContext.TenantName = findTenantName(rpContext.RequestedPathAndQuery);
            rpContext.ApplicationName = findApplicationName(rpContext.RequestedPathAndQuery);

            if ((!string.IsNullOrEmpty(rpContext.TenantName)) && (!string.IsNullOrEmpty(rpContext.ApplicationName)))
            {
                rpContext.ApplicationInstance = LoadBalancerControllerWebUtil.GetApplicationInstance(rpContext.TenantName, rpContext.ApplicationName);
                if (rpContext.ApplicationInstance != null)
                {
                    // Asynchronously add request to the load balancer request queue
                    rpContext.AddReqCaller = new ASyncAddRequestToQueue(AddRequestToQueue);
                    addReqResult = rpContext.AddReqCaller.BeginInvoke(context, rpContext.ApplicationInstance.NodeId,
                                                                               rpContext.ApplicationInstance.ApplicationId,
                                                                               rpContext.ApplicationInstance.Id,
                                                                               rpContext.ApplicationInstance.Tenant.Id, null, null);
                }
            }

            delegate_ = new AsyncProcessorDelegate(ReverseProxyRequest);
            return delegate_.BeginInvoke(context, rpContext, cb, extraData);
        }