From 5b723fe7a482fc522afb45c27665988b88aabb4b Mon Sep 17 00:00:00 2001 From: cflakes Date: Tue, 23 Mar 2010 18:03:12 +0000 Subject: [PATCH] WebSock: Add PAGE_DONE to EPageReqResult. It's used to better differentiate between async processing (PAGE_DEFERRED) and redirects and other synchronous stuff (-> PAGE_DONE). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1842 726aef4b-f618-498e-8847-2d620e286838 --- WebModules.cpp | 13 ++++++++----- WebModules.h | 7 ++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/WebModules.cpp b/WebModules.cpp index c2eddba7..5c9d5fdc 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -414,7 +414,7 @@ CWebSock::EPageReqResult CWebSock::PrintStaticFile(const CString& sPath, CString SetPaths(pModule); DEBUG("About to print [" + m_Template.ExpandFile(sPath) + "]"); if (PrintFile(m_Template.ExpandFile(sPath.TrimLeft_n("/")))) { - return PAGE_DEFERRED; + return PAGE_DONE; } else { return PAGE_NOTFOUND; } @@ -507,7 +507,10 @@ void CWebSock::OnPageRequest(const CString& sURI) { PrintPage(sPageRet); break; case PAGE_DEFERRED: - // Something else will later do these calls + // Something else will later call Close() + break; + case PAGE_DONE: + // Redirect or something like that, it's done, Close() has been called break; default: PrintNotFound(); @@ -538,7 +541,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS Redirect("/"); // We already sent a reply - return PAGE_DEFERRED; + return PAGE_DONE; } else if (sURI == "/login" || sURI.Left(7) == "/login/") { if (GetParam("submitted").ToBool()) { m_sUser = GetParam("user"); @@ -557,7 +560,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS // Make sure modules are treated as directories if (sURI.Right(1) != "/" && sURI.find(".") == CString::npos && sURI.TrimLeft_n("/mods/").TrimLeft_n("/").find("/") == CString::npos) { Redirect(sURI + "/"); - return PAGE_DEFERRED; + return PAGE_DONE; } if (m_sModName.empty()) { @@ -569,7 +572,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS if (!pModule && m_sForceUser.empty()) { if (!ForceLogin()) { - return PAGE_DEFERRED; + return PAGE_DONE; } pModule = CZNC::Get().FindModule(m_sModName, m_spSession->GetUser()); diff --git a/WebModules.h b/WebModules.h index a471b60b..49d81d59 100644 --- a/WebModules.h +++ b/WebModules.h @@ -113,9 +113,10 @@ class CWebSessionMap : public TCacheMap > { class CWebSock : public CHTTPSock { public: enum EPageReqResult { - PAGE_NOTFOUND, - PAGE_PRINT, - PAGE_DEFERRED + PAGE_NOTFOUND, // print 404 and Close() + PAGE_PRINT, // print page contents and Close() + PAGE_DEFERRED, // async processing, Close() will be called from a different place + PAGE_DONE // all stuff has been done and Close() has been called (e.g. by CHTTPSock::Redirect) }; CWebSock(CModule* pModule);