Esempio n. 1
0
        /// <summary>
        /// We will serve the ../html/index.html page as a sample.
        /// </summary>
        /// <param name="ioc">Ioc.</param>
        public override void ExecuteRequest(IOConn ioc)
        {
            using (EnEx ee = new EnEx ("ActionLogic::ExecuteRequest(IOConn ioc)")) {

                // Send a simple welcome page back to the caller:
                String html = "../html/index.html";
                DateTime lastModified = File.GetLastWriteTime( html );
                Byte[] data = File.ReadAllBytes( html );

                ioc.SendReturn(data, html, lastModified, DateTime.Now );

                ioc.Close();
            }
        }
Esempio n. 2
0
        public void removeSession(IOConn ioc, string sessionGUID)
        {
            using (EnEx ee = new EnEx ("SessionList::removeSession(IOConn ioc, string sessionGUID)")) {
                lock(m_sessions_mutex){
                    Log.Debug("Attempting to remove session ({0})", sessionGUID );

                    if(m_sessions.ContainsKey(sessionGUID)0){
                        try {
                            SessionSerializer.EnsureSessionDir();
                            string fileName = "./sessions/" + sessionGUID;
                            Log.Debug("Removing session file ({0})", fileName );
                            File.Delete( fileName );

                            Log.Debug("Removing session ({0}) from session list", sessionGUID );
                            m_sessions.Remove(sessionGUID);

                        } catch (Exception e){
                            Log.Error("Error deactivating session: {0}", e.Message);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void loadUserProperties(SessionInfo si, IOConn ioc)
        {
            using (EnEx ee = new EnEx ("SessionList::loadUserProperties(SessionInfo si, IOConn ioc)")) {

            }
        }
Esempio n. 4
0
 public void expireSessions(DateTime oldest, IOConn ioc, string dbname)
 {
     using (EnEx ee = new EnEx ("SessionList::expireSessions(DateTime oldest, IOConn ioc, string dbname)")) {
         foreach(SessionInfo si in getSessions()){
             if(si.dbname == dbname && si.created < oldest ) {
                 removeSession( ioc, si.sessionGUID );
             }
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// We handle serving the given URL request.
        /// </summary>
        /// <param name="ioc">Ioc.</param>
        public override void ExecuteRequest(IOConn ioc)
        {
            using (EnEx ee = new EnEx ("ActionHtml::ExecuteRequest()")) {
                // What's the page?
                string html_page = ioc.MsgTarget ();

                if (html_page == "/") {
                    html_page = "/index.html";
                }

                string html = "..";
                DateTime expires = DateTime.Now.AddDays (1);

                try {
                    // Check for a qd/page first:
                    if(html_page.StartsWith("/qd/")){
                        // Accomodate our unit testing applications:
                        if(html_page.Contains("/test/html/layouts/")){
                            html_page.Replace(
                                "/test/html/layouts/",
                                "/build/layouts/"
                            );
                        }
                        html = "../../.." + html_page;
                        // don't expire these pages, they change all the time
                        expires.AddDays(-2);
                    } else if( html_page.StartsWith("/qooxdoo_toolkit")){
                        html = ".." + html_page;
                        // these are static, expires is just fine.
                        expires.AddYears(1);
                    } else if(html_page.StartsWith("/qooxdoo-contrib")){
                        html = ".." + html_page;
                        // these are static, expires is just fine
                        expires.AddYears(1);
                    } else if(html_page.StartsWith("/3rdParty/qooxdoo")){
                        html = "../../../.." + html_page;
                        // these are static, expires is just fine
                        expires.AddYears(1);
                    } else if(html_page.StartsWith("/logfile")){
                        html = "." + html_page.Substring(8);
                        // don't expire these pages, let the last-modified checks work
                        expires.AddDays(-2);
                    } else if(html_page.StartsWith("/forwardtosupport/")){
                        html = "." + html_page;
                        // don't expire these pages, let the last-modified checks work
                        expires.AddDays(-2);
                    } else {
                        // Load the page from our html folder:
                        html = "../../../html" + html_page;
                        // don't expire these pages, let the last-modified checks work
                        expires.AddDays(-2);
                    }

                    HttpConn hioc = (HttpConn)ioc;
                    DateTime ims = hioc.GetIfModifiedSince();
                    DateTime lastModified = File.GetLastWriteTime( html );

                    if(lastModified <= ims){
                        Log.Debug("Url {0} LastMod ({1}) < IfModSince ({2}) - Sending Not Modified",
                            html_page, lastModified, ims );

                        hioc.SendNotModified();
                    } else {
                        // Send the data
                        Byte[] data = File.ReadAllBytes( html );

                        Log.Debug("Serving ({0}) from ({1}) with size ({2})", html_page, html, data.Length );
                        ioc.SendReturn(data, html, lastModified, expires );

                    }
                    ioc.Close();

                } catch (Exception){
                    Log.Info ("Sending NotFound for request({0})", html_page);
                    ioc.SendNotFound ();
                    ioc.Close ();
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Must be implemented by children - this will do the work of actually executing
 /// the logic represented by this task.
 /// </summary>
 /// <param name="ioc">Ioc.</param>
 public abstract void ExecuteRequest(IOConn ioc);