Esempio n. 1
0
        public async void Execute(HttpRequest request, HttpResponse response, UrlRouteServerGroup.UrlServerInfo serverInfo, Routes.UrlRoute urlRoute)
        {
            try
            {
                var clientAgent = await PopClient();

                if (clientAgent == null)
                {
                    string error = $"Unable to reach {Host}:{Port} HTTP request, exceeding maximum number of connections";
                    Events.EventResponseErrorArgs erea = new Events.EventResponseErrorArgs(request, response,
                                                                                           Gateway, error, Gateway.SERVER_MAX_OF_CONNECTIONS);
                    Gateway.OnResponseError(erea);
                }
                else
                {
                    RequestAgent agent = new RequestAgent(clientAgent, this, request, response, serverInfo, urlRoute);
                    agent.Completed = OnCompleted;
                    Gateway.AddRequest(agent);
                    //agent.Execute();
                }
            }
            catch (Exception e_)
            {
                if (urlRoute.Gateway.HttpServer.EnableLog(LogType.Error))
                {
                    urlRoute.Gateway.HttpServer.Log(LogType.Error, $"gateway {request.Url} route to {Uri} error {e_.Message}{e_.StackTrace}");
                }
            }
        }