From b0101a6df1091dff5366ea84a9efdabd66e90026 Mon Sep 17 00:00:00 2001 From: Ingmar Runge Date: Sun, 10 Mar 2013 00:28:19 +0100 Subject: [PATCH] Get rid of empty CHTTPSock::WriteFileGzipped method if there's no zlib. It's still in the header, but this does not have any negative side effects. --- src/HTTPSock.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/HTTPSock.cpp b/src/HTTPSock.cpp index 9ada62b4..2508cba5 100644 --- a/src/HTTPSock.cpp +++ b/src/HTTPSock.cpp @@ -307,18 +307,18 @@ bool CHTTPSock::PrintFile(const CString& sFileName, CString sContentType) { } #ifdef HAVE_ZLIB - bool bGzip = (sContentType.Left(5).Equals("text/") || sFileName.Right(3).Equals(".js")); -#else - bool bGzip = false; // hello optimizer -#endif - if (!bGzip || !m_bAcceptGzip) { - PrintHeader(iSize, sContentType); - WriteFileUncompressed(File); - } else { + bool bGzip = m_bAcceptGzip && (sContentType.Left(5).Equals("text/") || sFileName.Right(3).Equals(".js")); + + if (bGzip) { DEBUG("- Sending gzip-compressed."); AddHeader("Content-Encoding", "gzip"); PrintHeader(0, sContentType); // we do not know the compressed data's length WriteFileGzipped(File); + } else +#endif + { + PrintHeader(iSize, sContentType); + WriteFileUncompressed(File); } } @@ -346,8 +346,8 @@ void CHTTPSock::WriteFileUncompressed(CFile& File) { } } -void CHTTPSock::WriteFileGzipped(CFile& File) { #ifdef HAVE_ZLIB +void CHTTPSock::WriteFileGzipped(CFile& File) { char szBufIn[8192]; char szBufOut[8192]; off_t iFileSize = File.GetSize(), iFileReadTotal = 0; @@ -398,8 +398,8 @@ void CHTTPSock::WriteFileGzipped(CFile& File) { } while (zStatus == Z_OK); deflateEnd(&zStrm); -#endif } +#endif void CHTTPSock::ParseURI() { ParseParams(m_sURI.Token(1, true, "?"), m_msvsGETParams);