Tornado.web.Application.Call C# (CSharp) Method

Call() public method

public Call ( HTTPRequest request ) : RequestHandler
request Tornado.httpserver.HTTPRequest
return RequestHandler
        public RequestHandler Call(HTTPRequest request)
        {
            // Called by HTTPServer to execute the request.
            var transforms_ = transforms.Select(t => t(request)).ToList();
            RequestHandler handler = null;
            var args = new List<string>();
            var kwargs = new Dictionary<string, string>();
            var handlers_ = _get_host_handlers(request);
            if (handlers == null || !handlers.Any())
                handler = new RedirectHandler(this, 
                    request, new Dictionary<string, object>(){{"url", "http://" + default_host + "/"}});
            else
            {
                foreach (var spec in handlers_)
                {
                    var match = spec.regex.IsMatch(request.path);
                    if (match)
                    {
                        handler = spec.handler_class(this, request, spec.kwargs);
                        // todo implement args
                        /*if spec.regex.groups:
                            // None-safe wrapper around url_unescape to handle
                            // unmatched optional groups correctly
                            def unquote(s):
                                if s is None:
                                    return s
                                return escape.url_unescape(s, encoding=None)
                            // Pass matched groups to the handler.  Since
                            // match.groups() includes both named and unnamed groups,
                            // we want to use either groups or groupdict but not both.
                            // Note that args are passed as bytes so the handler can
                            // decide what encoding to use.

                            if spec.regex.groupindex:
                                kwargs = dict(
                                    (str(k), unquote(v))
                                    for (k, v) in match.groupdict().iteritems())
                            else:
                                args = [unquote(s) for s in match.groups()]*/
                        break;
                    }
                }
                if (handler == null)
                    handler = new ErrorHandler(this, request, new Dictionary<string, object>{{"status_code", 404}});
            }
            // In debug mode, re-compile templates and reload static files on every
            // request so you don't need to restart to see changes
            /*if self.settings.get("debug"):
                with RequestHandler._template_loader_lock:
                    for loader in RequestHandler._template_loaders.values():
                        loader.reset()
                StaticFileHandler.reset()*/

            handler._execute(transforms_, args, kwargs);
            return handler;
        }
    }