Ejemplo n.º 1
0
        public void Execute(HttpServer.IHttpClientContext context, HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            var filePath = request.Uri.LocalPath;

            // Prevent hacking
            filePath = filePath.Replace('/', '\\');
            filePath = filePath.Substring(filePath.LastIndexOf('\\'));

            if (filePath[0] == '\\')
            {
                filePath = filePath.Substring(1);
            }

            response.Connection = HttpServer.ConnectionType.Close;
            try
            {
                var content = TemplateTools.ReadResourceFile(filePath);
                response.ContentType   = GetMimeTypeByExtension(filePath);
                response.ContentLength = content.Length;
                response.SendHeaders();

                response.SendBody(content);
            }
            catch
            {
                response.Reason = "HTTP/1.1 404 Not Found";
                response.Send();
            }
        }
Ejemplo n.º 2
0
        public void Execute(HttpServer.IHttpClientContext context, HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (!request.Param.Contains("number"))
            {
                return;
            }

            var call = _plugin.PluginManager.Core.CallManager.MakeCall(request.Param["number"].Value);

            var content = TemplateTools.ProcessTemplate(
                "Call.html",
                new Dictionary <string, string>()
            {
                { "number", call.Number }
            });

            response.Connection    = HttpServer.ConnectionType.Close;
            response.ContentType   = "text/html";
            response.ContentLength = content.Length;
            response.AddHeader("Content-type", "text/html");
            response.SendHeaders();

            response.SendBody(content);

            //response.Connection = HttpServer.ConnectionType.Close;
            //response.Redirect(String.Format("/callstate?call_id={0}", call.SessionId));
            //response.Send();
        }
Ejemplo n.º 3
0
        public void Execute(HttpServer.IHttpClientContext context, HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (!request.Param.Contains("call_id"))
            {
                return;
            }

            var call = _plugin.PluginManager.Core.CallManager[Int32.Parse(request.Param["call_id"].Value)];

            var content = TemplateTools.ProcessTemplate(
                "CallState.html",
                new Dictionary <string, string>()
            {
                { "number", call.Number },
                { "state", ConvertState(call.State) }
            });

            response.Connection    = HttpServer.ConnectionType.Close;
            response.ContentType   = "text/html";
            response.ContentLength = content.Length;
            response.AddHeader("Content-type", "text/html");
            response.SendHeaders();

            response.SendBody(content);
        }
Ejemplo n.º 4
0
        protected override void HandleRequest(HttpServer.IHttpClientContext context, HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            var handler = _handlerManager[request.Uri.LocalPath];

            if (handler != null)
            {
                try
                {
                    handler.Execute(context, request, response, session);
                }
                catch (Exception e)
                {
                    Logger.LogWarn(e);
                }
            }
            else
            {
                new FileHandler().Execute(context, request, response, session);
            }

            base.HandleRequest(context, request, response, session);
        }