Пример #1
0
        public static Task Process(IDictionary <string, object> env)
        {
            if (_aspunloading)
            {
                return(Task.FromResult <bool>(true));
            }
            if (_appHost == null)
            {
                lock (_lckCreateHost)
                {
                    if (_appHost == null)
                    {
                        CreateAspApplicationHost();
                    }
                }
            }
            if (_appHost == null)
            {
                return(null);
            }
            int            reqid = CreateId();
            ReqInfo        info  = new ReqInfo(env);
            AspRequestData data  = new AspRequestData(reqid, env);

            _tasks[reqid] = info;
            RealProcess(data);
            return(info.RequestWorkTask.Task);
        }
Пример #2
0
        public void ProcessRequest(AspRequestData req)
        {
            this._reqData = req;
            string s    = "";
            bool   flag = false;

            try
            {
                HttpRuntime.ProcessRequest(this);
            }
            catch (HttpException exception)
            {
                flag = true;
                s    = exception.GetHtmlErrorMessage();
            }
            catch (Exception exception2)
            {
                flag = true;
                s    = new HttpException(400, "Bad request", exception2).GetHtmlErrorMessage();
            }
            if (flag)
            {
                this.SendStatus(400, "Bad request");
                this.SendUnknownResponseHeader("Connection", "close");
                this.SendUnknownResponseHeader("Date", DateTime.Now.ToUniversalTime().ToString("r"));
                Encoding encoding = Encoding.UTF8;
                byte[]   bytes    = encoding.GetBytes(s);
                this.SendUnknownResponseHeader("Content-Type", "text/html; charset=" + encoding.WebName);
                this.SendUnknownResponseHeader("Content-Length", bytes.Length.ToString());
                this._keepAlive = false;
                this.SendResponseFromMemory(bytes, bytes.Length);
                this.FlushResponse(true);
            }
        }
Пример #3
0
 private static void RealProcess(AspRequestData data)
 {
     try
     {
         _appFunc(data);//真正的处理request请求
     }
     catch (Exception)
     {
         RequestEnd(data.RequestId, false);
     }
 }
Пример #4
0
 public void Process(AspRequestData req)
 {
     new AspRequestWorker().ProcessRequest(req);
 }