added: a new way: HEX format to saving/reading from PostgreSQL bytea columns
added: to Request: // binary page BinaryPage binary_page; // a compressed page ready to send to the client BinaryPage compressed_page; // if true then either page or ajaxpage will be sent to the client // if false then binary_page is sent // default: true bool use_text_page; BinaryPage is defined as (in requesttypes.h): typedef PT::TextStreamBase<char, 1, 4096> BinaryPage; added: to Compress: now it can gets BinaryPage as arguments (input, output) changed: winix version to: 0.5.0 added: in templates: TexTextStream class for taking input to the TeX typesetting system git-svn-id: svn://ttmath.org/publicrep/winix/trunk@884 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
84
core/app.cpp
84
core/app.cpp
@@ -977,6 +977,7 @@ void App::FilterCompressSend(bool compressing, int compress_encoding, const std:
|
||||
|
||||
|
||||
|
||||
|
||||
int App::SelectDeflateVersion()
|
||||
{
|
||||
if( cur.request->browser_msie )
|
||||
@@ -1070,7 +1071,7 @@ void App::AddDebugInfo(std::wstring & out)
|
||||
|
||||
|
||||
|
||||
void App::SendAnswer()
|
||||
void App::SendTextAnswer()
|
||||
{
|
||||
const std::wstring * source;
|
||||
Header header = h_200;
|
||||
@@ -1083,7 +1084,6 @@ int compress_encoding;
|
||||
else
|
||||
source = &cur.request->page.Str();
|
||||
|
||||
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
|
||||
@@ -1102,6 +1102,86 @@ int compress_encoding;
|
||||
}
|
||||
|
||||
|
||||
void App::SendData(const BinaryPage & page, FCGX_Stream * out)
|
||||
{
|
||||
const size_t buf_size = 4096;
|
||||
|
||||
if( send_data_buf.size() != buf_size )
|
||||
send_data_buf.resize(buf_size);
|
||||
|
||||
BinaryPage::const_iterator i = page.begin();
|
||||
BinaryPage::const_iterator end = page.end();
|
||||
|
||||
// log << log1 << "size: " << page.size() << logend;
|
||||
|
||||
// for(size_t x=0 ; x<page.size() ; ++x)
|
||||
// log << int((unsigned char)page[x]) << ' ';
|
||||
|
||||
// log << logend;
|
||||
|
||||
while( i != end )
|
||||
{
|
||||
size_t s = 0;
|
||||
|
||||
for( ; i != end && s < buf_size ; ++i, ++s)
|
||||
{
|
||||
send_data_buf[s] = *i;
|
||||
|
||||
// log << "swinka: " << int((unsigned char)*i) << logend;
|
||||
}
|
||||
|
||||
if( s > 0 )
|
||||
FCGX_PutStr(send_data_buf.c_str(), s, fcgi_request.out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::SendBinaryAnswer()
|
||||
{
|
||||
BinaryPage & source = cur.request->binary_page;
|
||||
BinaryPage & compressed_page = cur.request->compressed_page;
|
||||
Header header = h_200;
|
||||
Error status = cur.request->status;
|
||||
bool compressing;
|
||||
int compress_encoding;
|
||||
|
||||
|
||||
SelectCompression(source.size(), compressing, compress_encoding);
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
|
||||
header = h_404;
|
||||
|
||||
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
|
||||
header = h_403;
|
||||
|
||||
// !! IMPROVE ME add header: content-size
|
||||
|
||||
SendHeaders(compressing, compress_encoding, header);
|
||||
|
||||
if( CanSendContent(header) )
|
||||
{
|
||||
if( compressing )
|
||||
{
|
||||
compress.Compressing(source, compressed_page, compress_encoding);
|
||||
SendData(compressed_page, fcgi_request.out);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendData(source, fcgi_request.out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void App::SendAnswer()
|
||||
{
|
||||
if( cur.request->use_text_page )
|
||||
SendTextAnswer();
|
||||
else
|
||||
SendBinaryAnswer();
|
||||
}
|
||||
|
||||
|
||||
void App::LogUser(const char * msg, uid_t id)
|
||||
{
|
||||
log << log3 << msg << " ";
|
||||
|
Reference in New Issue
Block a user