예제 #1
0
 /// <summary>
 /// Remove a Website
 /// </summary>
 /// <param name="website"></param>
 public void RemoveWebsite(HttpWebsite website)
 {
     if (!sites.Contains(website))
     {
         sites.Remove(website);
     }
 }
예제 #2
0
 /// <summary>
 /// Add a Website
 /// </summary>
 /// <param name="website"></param>
 public void AddWebsite(HttpWebsite website)
 {
     if (!sites.Contains(website))
     {
         sites.Insert(0, website);
     }
 }
예제 #3
0
 internal HttpClient(Socket handle, HttpWebServer server)
 {
     this.handle = handle;
     this.server = server;
     this.website = HttpWebsite.InternalWebsite;
     this.buffer = new byte[buffersize];
     this.request = new HttpRequest(this);
     this.response = new HttpResponse();
     handle.ReceiveTimeout = 30 * 1000;
 }
예제 #4
0
 public ActivePageModule(HttpWebsite website)
 {
     this.website = website;
 }
예제 #5
0
 public ErrorModule(HttpWebsite website)
 {
     this.website = website;
     this.ErrorPagePath = website.Config!=null?website.Config.ErrorPagePath:"";
 }
예제 #6
0
        private void Process()
        {
            try
            {

                this.website = server.GetWebSite(request.headers[eHttpRequestHeader.Host]);
                if (this.website == HttpWebsite.InternalWebsite)
                {
                    request.ErrorCode = 403;
                    return;
                }
                else
                {
                    request.client = this;
                    IModule module = null;

                    foreach (var x in website.modules)
                    {
                        if (x.CanProcess(request))
                        {
                            module = x;
                            break;
                        }
                    }
                    if (module != null)
                    {
                        response = module.Process(request);
                        if (!response.IsError)
                        {
                            response.Cookies.Add(new HttpCookie { name = "SessionID", content = request.Session.ID, Expires = DateTime.Now.AddHours(1) });
                        }

                        Response();
                    }
                    else
                    {
                        request.ErrorCode = 501;
                        SendErrorAndDisconnect();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Log.Default.Warn(e);
                request.ErrorCode = 500;
                SendErrorAndDisconnect();
                //throw;
            }
        }