2008-12-10 05:42:49 +01:00
|
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
|
* This file is a part of Winix
|
2008-12-10 05:42:49 +01:00
|
|
|
|
* and is not publicly distributed
|
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
|
#ifndef headerfile_winix_core_request
|
|
|
|
|
#define headerfile_winix_core_request
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
#include <fcgiapp.h>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "requesttypes.h"
|
|
|
|
|
#include "item.h"
|
|
|
|
|
#include "error.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
|
#include "config.h"
|
2010-11-21 01:19:17 +01:00
|
|
|
|
#include "textstream.h"
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
|
#include "templates/htmltextstream.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
|
2010-06-30 20:42:50 +02:00
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
class FunctionBase;
|
|
|
|
|
|
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
struct Request
|
|
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
|
// request id
|
|
|
|
|
// is incremented for each request and is never 0
|
|
|
|
|
// (from -1 will be incremented twice)
|
2010-07-04 22:27:14 +02:00
|
|
|
|
// it's used for some optimalizations e.g. in templates
|
2008-12-30 02:05:03 +01:00
|
|
|
|
size_t id;
|
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
// !! moze pozbyc sie tego none?
|
|
|
|
|
enum Method { get, post, head, none } method;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
enum Role { responder, authorizer } role;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
// headers, page and debug
|
2010-11-21 01:19:17 +01:00
|
|
|
|
//std::ostringstream headers, page, debug;
|
|
|
|
|
TextStream<std::string> headers;
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
|
HtmlTextStream page, debug;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
|
// raw parameters
|
|
|
|
|
GetTab get_tab;
|
|
|
|
|
PostTab post_tab;
|
|
|
|
|
PostFileTab post_file_tab;
|
|
|
|
|
CookieTab cookie_tab;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
|
// environment variables
|
2009-11-17 02:04:01 +01:00
|
|
|
|
// they are not null -- when the server doesn't have such a variable
|
|
|
|
|
// it will be pointing into 'char_empty' which is default '\0'
|
2008-12-10 05:42:49 +01:00
|
|
|
|
const char * env_request_method;
|
|
|
|
|
const char * env_request_uri;
|
|
|
|
|
const char * env_http_cookie;
|
2008-12-11 03:46:16 +01:00
|
|
|
|
const char * env_remote_addr;
|
2008-12-12 04:11:29 +01:00
|
|
|
|
const char * env_http_host;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
const char * env_http_user_agent;
|
2009-10-08 19:59:10 +02:00
|
|
|
|
const char * env_http_accept_encoding;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
const char * env_fcgi_role;
|
2010-01-06 20:17:53 +01:00
|
|
|
|
const char * env_content_type;
|
2009-10-08 19:59:10 +02:00
|
|
|
|
|
|
|
|
|
// true if the browser is Microsoft Internet Explorer
|
|
|
|
|
bool browser_msie;
|
|
|
|
|
|
2009-12-19 20:46:15 +01:00
|
|
|
|
// true if the browser is Konqueror
|
|
|
|
|
bool browser_konqueror;
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
// current directory
|
2010-08-10 22:43:38 +02:00
|
|
|
|
std::vector<Item*> dir_tab;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
|
// true if a file exists
|
2008-12-30 02:05:03 +01:00
|
|
|
|
bool is_item;
|
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
|
// current file (if exists)
|
2008-12-30 02:05:03 +01:00
|
|
|
|
Item item;
|
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
// current winix function
|
2008-12-30 02:05:03 +01:00
|
|
|
|
// null if there is no a function
|
2010-08-10 22:43:38 +02:00
|
|
|
|
FunctionBase * function;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
2010-07-04 22:27:14 +02:00
|
|
|
|
// parameters (name:value)
|
2010-08-10 22:43:38 +02:00
|
|
|
|
ParamTab param_tab;
|
|
|
|
|
|
|
|
|
|
// request status
|
2008-12-30 02:05:03 +01:00
|
|
|
|
Error status;
|
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
|
// usually items in the current directory (depends on the function)
|
|
|
|
|
std::vector<Item> item_tab;
|
2010-01-25 05:52:17 +01:00
|
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
|
// if not empty means an address for redirecting to
|
2010-11-21 01:19:17 +01:00
|
|
|
|
std::wstring redirect_to;
|
|
|
|
|
std::string aredirect_to;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
2010-02-19 00:30:22 +01:00
|
|
|
|
// send header X-LIGHTTPD-send-file with path to a file
|
2010-11-21 01:19:17 +01:00
|
|
|
|
std::wstring x_sendfile;
|
2010-02-19 00:30:22 +01:00
|
|
|
|
|
|
|
|
|
// send as attachment (causing header: content-disposition: attachment)
|
|
|
|
|
bool send_as_attachment;
|
|
|
|
|
|
2010-08-14 16:45:25 +02:00
|
|
|
|
// this is a pointer either to the item (if exists) or to the last directory
|
|
|
|
|
Item * last_item;
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Request();
|
|
|
|
|
void SetConfig(Config * pconfig);
|
|
|
|
|
void Clear();
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
// for debugging
|
2010-08-10 22:43:38 +02:00
|
|
|
|
void PrintGetTab();
|
2010-11-23 22:52:25 +01:00
|
|
|
|
//void PrintEnv();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
|
bool IsParam(const wchar_t * param_name);
|
|
|
|
|
bool IsParam(const std::wstring & param_name);
|
2011-02-11 22:37:28 +01:00
|
|
|
|
const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter
|
|
|
|
|
const std::wstring & ParamValue(const std::wstring & param_name); // returns empty string if there is no such a parameter
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
|
void SetCookie(const char * name, const char * value, tm * expires = 0);
|
|
|
|
|
void SetCookie(const char * name, long value, tm * expires = 0);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
|
bool IsPostVar(const wchar_t * var);
|
|
|
|
|
const std::wstring & PostVar(const wchar_t * var); // !! zamienic na referencje nie do sta<74>ej (bez const)
|
|
|
|
|
bool PostVar(const wchar_t * var, std::wstring & result);
|
|
|
|
|
std::wstring * PostVarp(const wchar_t * var);
|
2010-09-30 22:58:20 +02:00
|
|
|
|
|
2009-12-09 01:42:40 +01:00
|
|
|
|
bool AllPostVarEmpty(); // returning true if all post vars are empty
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
void SendAll();
|
2010-08-12 21:10:12 +02:00
|
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
|
private:
|
2009-10-08 19:59:10 +02:00
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
Config * config;
|
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
void ClearPostFileTmp();
|
2009-12-09 01:42:40 +01:00
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
// contains '\0'
|
|
|
|
|
// used to set env_* pointers to the empty value
|
2008-12-12 04:11:29 +01:00
|
|
|
|
const char char_empty;
|
2009-11-17 00:36:38 +01:00
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
// used in ParamValue() and PostVar() when there is no such a param
|
2010-11-21 01:19:17 +01:00
|
|
|
|
const std::wstring str_empty;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|