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);