added: support for output compression

git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@511 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2009-09-21 23:05:05 +00:00
parent 394c7b22a2
commit 9902ce2b78
14 changed files with 329 additions and 71 deletions

View File

@@ -14,13 +14,18 @@
#include "log.h"
#include "data.h"
Request::Request() : char_empty(0)
{
id = 0;
Clear();
}
void Request::Init()
{
compress.Init();
}
void Request::Clear()
{
@@ -319,6 +324,9 @@ void Request::SendAll()
FCGX_PutS("Status: 200 OK\r\n", out);
FCGX_PutS("Content-Type: Text/Html\r\n", out);
}
if( data.compression )
FCGX_PutS("Content-Encoding: deflate\r\n", out);
FCGX_PutS(headers.str().c_str(), out);
FCGX_PutS("\r\n", out);
@@ -327,9 +335,16 @@ void Request::SendAll()
if( result == redirect )
// if there is a redirect we do not send a content
return;
//
FCGX_PutS(page.str().c_str(), out);
const std::string & source = page.str();
if( !data.compression || compress.CompressAndPut(source.c_str(), source.length(), out) != 0 )
{
// there were problems during compressing, or we don't use compression at all
FCGX_PutS(source.c_str(), out);
}
const std::string & d = debug.str();
if( !d.empty() )