From: <ps...@us...> - 2010-06-22 15:26:24
|
Revision: 2040 http://znc.svn.sourceforge.net/znc/?rev=2040&view=rev Author: psychon Date: 2010-06-22 15:26:17 +0000 (Tue, 22 Jun 2010) Log Message: ----------- Remove CHTTPSock::GetErrorPage() There is no valid reason to use GetErrorPage() instead of PrintErrorPage() which can be seen from the fact that all the existing callers are *wrong*. So, to avoid this mistake in the future, inline GetErrorPage() into its only valid caller (PrintErrorPage()). Modified Paths: -------------- trunk/HTTPSock.cpp trunk/HTTPSock.h Modified: trunk/HTTPSock.cpp =================================================================== --- trunk/HTTPSock.cpp 2010-06-22 15:18:56 UTC (rev 2039) +++ trunk/HTTPSock.cpp 2010-06-22 15:26:17 UTC (rev 2040) @@ -403,7 +403,14 @@ return false; } - CString sPage = GetErrorPage(uStatusId, sStatusMsg, sMessage); + CString sPage = + "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" + "<html><head>\r\n<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n" + "</head><body>\r\n<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n" + "<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n" + "<hr />\r\n<address>" + CZNC::GetTag(false).Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n" + "</body></html>\r\n"; + PrintHeader(sPage.length(), "text/html", uStatusId, sStatusMsg); Write(sPage); Close(Csock::CLT_AFTERWRITE); @@ -411,15 +418,6 @@ return true; } -CString CHTTPSock::GetErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage) { - return "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" - "<html><head>\r\n<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n" - "</head><body>\r\n<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n" - "<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n" - "<hr />\r\n<address>" + CZNC::GetTag(false).Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n" - "</body></html>\r\n"; -} - bool CHTTPSock::ForceLogin() { if (m_bLoggedIn) { return true; @@ -430,11 +428,8 @@ return false; } - CString sPage = GetErrorPage(401, "Unauthorized", "You need to login to view this page."); AddHeader("WWW-Authenticate", "Basic realm=\"" + CZNC::GetTag(false) + "\""); - PrintHeader(sPage.length(), "text/html", 401, "Unauthorized"); - Write(sPage); - Close(Csock::CLT_AFTERWRITE); + PrintErrorPage(401, "Unauthorized", "You need to login to view this page."); return false; } @@ -504,11 +499,8 @@ } DEBUG("- Redirect to [" << sURL << "]"); - CString sPage = GetErrorPage(302, "Found", "The document has moved <a href=\"" + sURL.Escape_n(CString::EHTML) + "\">here</a>."); AddHeader("Location", sURL); - PrintHeader(sPage.length(), "text/html", 302, "Found"); - Write(sPage); - Close(Csock::CLT_AFTERWRITE); + PrintErrorPage(302, "Found", "The document has moved <a href=\"" + sURL.Escape_n(CString::EHTML) + "\">here</a>."); return true; } Modified: trunk/HTTPSock.h =================================================================== --- trunk/HTTPSock.h 2010-06-22 15:18:56 UTC (rev 2039) +++ trunk/HTTPSock.h 2010-06-22 15:26:17 UTC (rev 2040) @@ -45,7 +45,6 @@ bool PrintNotFound(); bool Redirect(const CString& sURL); - CString GetErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage); bool PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage); static void ParseParams(const CString& sParams, map<CString, VCString>& msvsParams); void ParseURI(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |