From 49df8dc27d136f4bae6dbb03c9703232619742e1 Mon Sep 17 00:00:00 2001 From: cflakes Date: Mon, 5 Apr 2010 15:17:23 +0000 Subject: [PATCH] Clarify the meaning of returning false from OnWebRequest. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1886 726aef4b-f618-498e-8847-2d620e286838 --- Modules.h | 1 + WebModules.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules.h b/Modules.h index 4eea5031..30480efd 100644 --- a/Modules.h +++ b/Modules.h @@ -299,6 +299,7 @@ public: * @param sPageName The name of the page that has been requested. * @param Tmpl The active template. You can add variables, loops and stuff to it. * @return You MUST return true if you want the template to be evaluated and sent to the browser. + * Return false if you called Redirect() or PrintErrorPage(). If you didn't, a 404 page will be sent. */ virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl); /** Registers a sub page for the sidebar. diff --git a/WebModules.cpp b/WebModules.cpp index 0bf57257..f4d988d5 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -639,12 +639,19 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS } else { SetPaths(pModule, true); + /* if a module returns false from OnWebRequest, it does not + want the template to be printed, usually because it did a redirect. */ if (pModule->OnWebRequest(*this, m_sPage, m_Template)) { return PrintTemplate(m_sPage, sPageRet, pModule); } - sPageRet = GetErrorPage(404, "Not Implemented", "The requested module does not acknowledge web requests"); - return PAGE_PRINT; + if (!SentHeader()) { + sPageRet = GetErrorPage(404, "Not Implemented", "The requested module does not acknowledge web requests"); + return PAGE_PRINT; + } else { + Close(CLT_AFTERWRITE); // make sure the connection is going to be closed + return PAGE_DONE; + } } } else { CString sPage(sURI.Trim_n("/"));