changed: now we do not use std::string and char* in the Winix API

everywhere we are using std::wstring and wchar_t*
         (std::string and char* is used only locally in some places
         especially when creating a path to OS file system etc.)
added:   to the special thread when winix closes:
         a write function for curl: FetchPageOnExitCurlCallback()
         without this function the curl library will print
         the page's content to the standart output
changed: TextStream<> class from core can make
         UTF8<->wide strings conversions
removed: from config: utf8 option
         now winix expects UTF8 from the user's input (html forms, url-es)
         and outputs strings in the UTF8 format




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@965 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-09 20:44:56 +00:00
parent 4abf6642f7
commit 8196fb77d1
74 changed files with 1911 additions and 1612 deletions

View File

@@ -35,7 +35,6 @@
#ifndef headerfile_winix_core_cookieparser
#define headerfile_winix_core_cookieparser
#include <fcgiapp.h>
#include "httpsimpleparser.h"
#include "requesttypes.h"
#include "log.h"
@@ -49,10 +48,8 @@ namespace Winix
class CookieParser : public HttpSimpleParser
{
const char * cookie_string;
const wchar_t * cookie_string;
CookieTab * cookie_tab;
std::wstring temp_name, temp_value;
bool input_as_utf8;
protected:
@@ -63,32 +60,23 @@ protected:
if( !cookie_string || *cookie_string == 0 )
return -1;
return (int)(unsigned char)*(cookie_string++);
}
void ConvStr(const std::string & src, std::wstring & dst)
{
if( input_as_utf8 )
PT::UTF8ToWide(src, dst);
else
AssignString(src, dst);
return (int)*(cookie_string++);
}
virtual void Parameter(std::string & name, std::string & value)
virtual void Parameter(std::wstring & name, std::wstring & value)
{
// Cookie names are case insensitive according to section 3.1 of RFC 2965
// (we don't use locale here)
ToLower(name);
ConvStr(name, temp_name);
ConvStr(value, temp_value);
std::pair<CookieTab::iterator, bool> res = cookie_tab->insert( std::make_pair(temp_name, temp_value) );
log << log2 << "Cookie, name: \"" << temp_name << "\", value: \"" << temp_value << "\"";
std::pair<CookieTab::iterator, bool> res = cookie_tab->insert( std::make_pair(name, value) );
log << log2 << "Cookie, name: \"" << name << "\", value: \"" << value << "\"";
if( res.second == false )
{
res.first->second = temp_value;
res.first->second = value;
log << " (overwritten)";
}
@@ -101,28 +89,28 @@ public:
CookieParser()
{
input_as_utf8 = false;
HttpSimpleParser::separator = ';';
HttpSimpleParser::value_can_be_quoted = true;
HttpSimpleParser::skip_white_chars = true;
HttpSimpleParser::recognize_special_chars = false;
HttpSimpleParser::separator = ';';
HttpSimpleParser::value_can_be_quoted = true;
HttpSimpleParser::skip_white_chars = true;
HttpSimpleParser::recognize_special_chars = false;
HttpSimpleParser::getchar_returns_utf8_chars = false;
}
void UTF8(bool utf)
{
input_as_utf8 = utf;
}
// cookie_string can be null
void Parse(const char * cookie_string_, CookieTab & cookie_tab_)
void Parse(const wchar_t * cookie_string_, CookieTab & cookie_tab_)
{
cookie_string = cookie_string_;
cookie_tab = &cookie_tab_;
cookie_tab = &cookie_tab_;
HttpSimpleParser::Parse();
}
void Parse(const std::wstring & cookie_string_, CookieTab & cookie_tab_)
{
Parse(cookie_string_.c_str(), cookie_tab_);
}
};