From 0c0c51172efb0c9a302482162d147c2f87a51096 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 13 May 2010 15:54:06 +0000 Subject: [PATCH] WebModules: Make PAGE_DONE imply Close() When one now finishes a web request with PAGE_DONE, the code actively calls Close(CLT_AFTERWRITE) which one previously had to call explicitly. This means there is finally a difference between PAGE_DONE and PAGE_DEFERRED. ;) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1981 726aef4b-f618-498e-8847-2d620e286838 --- WebModules.cpp | 10 ++++++++-- WebModules.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WebModules.cpp b/WebModules.cpp index 34a8814d..7a1251c3 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -513,7 +513,9 @@ void CWebSock::OnPageRequest(const CString& sURI) { // Something else will later call Close() break; case PAGE_DONE: - // Redirect or something like that, it's done, Close() has been called + // Redirect or something like that, it's done, just make sure + // the connection will be closed + Close(CLT_AFTERWRITE); break; default: PrintNotFound(); @@ -656,6 +658,11 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS /* 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)) { + // If they already sent a reply, let's assume + // they did what they wanted to do. + if (SentHeader()) { + return PAGE_DONE; + } return PrintTemplate(m_sPage, sPageRet, pModule); } @@ -663,7 +670,6 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS 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; } } diff --git a/WebModules.h b/WebModules.h index d067dc32..a1dd43d4 100644 --- a/WebModules.h +++ b/WebModules.h @@ -114,7 +114,7 @@ public: 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) + PAGE_DONE // all stuff has been done }; CWebSock(CModule* pModule);