90 lines
1.4 KiB
C++
Executable File
90 lines
1.4 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfile_winix_core_postparser
|
|
#define headerfile_winix_core_postparser
|
|
|
|
#include <fcgiapp.h>
|
|
#include <string>
|
|
#include "httpsimpleparser.h"
|
|
#include "requesttypes.h"
|
|
#include "misc.h"
|
|
#include "utf8.h"
|
|
#include "log.h"
|
|
|
|
|
|
|
|
class PostParser : public HttpSimpleParser
|
|
{
|
|
|
|
FCGX_Stream * in;
|
|
PostTab * post_tab;
|
|
std::wstring temp_name, temp_value;
|
|
bool input_as_utf8;
|
|
|
|
protected:
|
|
|
|
|
|
virtual int GetChar()
|
|
{
|
|
return FCGX_GetChar(in);
|
|
}
|
|
|
|
|
|
virtual void Parameter(std::string & name, std::string & value)
|
|
{
|
|
if( input_as_utf8 )
|
|
{
|
|
Ezc::UTF8ToWide(name, temp_name);
|
|
Ezc::UTF8ToWide(value, temp_value);
|
|
}
|
|
else
|
|
{
|
|
AssignString(name, temp_name);
|
|
AssignString(value, temp_value);
|
|
}
|
|
|
|
std::pair<PostTab::iterator, bool> res = post_tab->insert( std::make_pair(temp_name, temp_value) );
|
|
|
|
log << log2 << "Method POST, name: \"" << temp_name << "\", value: \"" << temp_value << "\"";
|
|
|
|
if( res.second == false )
|
|
log << log2 << " (skipped)";
|
|
|
|
log << log2 << logend;
|
|
}
|
|
|
|
|
|
public:
|
|
|
|
PostParser()
|
|
{
|
|
input_as_utf8 = false;
|
|
}
|
|
|
|
|
|
void UTF8(bool utf)
|
|
{
|
|
input_as_utf8 = utf;
|
|
}
|
|
|
|
|
|
void Parse(FCGX_Stream * in_, PostTab & post_tab_)
|
|
{
|
|
in = in_;
|
|
post_tab = &post_tab_;
|
|
|
|
HttpSimpleParser::Parse();
|
|
}
|
|
|
|
};
|
|
|
|
|
|
#endif
|