208 lines
4.4 KiB
Raw Normal View History

* This file is a part of Winix
* and is not publicly distributed
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
#ifndef headerfilecmslucorerequest
#define headerfilecmslucorerequest
#include <fcgiapp.h>
#include <sstream>
#include <vector>
#include <iomanip>
#include "requesttypes.h"
#include "session.h"
#include "item.h"
#include "error.h"
#include "thread.h"
#include "compress.h"
#include "acceptencodingparser.h"
#include "htmlfilter.h"
#include "postmultiparser.h"
#include "ticket.h"
#include "config.h"
class FunctionBase;
struct Request
// request id
// is incremented for each request and is never 0
// (from -1 will be incremented twice)
// it's used for some optimalizations e.g. in templates
size_t id;
FCGX_Stream * in, * out, * err;
FCGX_ParamArray env; // defined as 'char **'
enum Method { get, post, none } method;
enum Role { responder, authorizer } role;
// headers, page and debug
// notify (for mailing)
std::ostringstream headers, page, debug, notify;
GetTable get_table;
PostTable post_table;
PostFileTable post_file_table;
CookieTable cookie_table;
// environment variables
// they are not null -- when the server doesn't have such a variable
// it will be pointing into 'char_empty' which is default '\0'
const char * env_request_method;
const char * env_request_uri;
const char * env_http_cookie;
const char * env_remote_addr;
const char * env_http_host;
const char * env_http_user_agent;
const char * env_http_accept_encoding;
const char * env_fcgi_role;
const char * env_content_type;
// true if the browser is Microsoft Internet Explorer
bool browser_msie;
// true if the browser is Konqueror
bool browser_konqueror;
// current session
// is set after calling session_manager.SetSession()
Session * session;
// current directory
std::vector<Item*> dir_table;
bool is_item;
// this item is used for many purposes such as editing, adding an item etc.
Item item;
// null if there is no a function
FunctionBase * pfunction;
// parameters (name:value)
ParamTable param_table;
Error status;
// last notify
int notify_code;
// items in the current directory
// maybe without contents?
std::vector<Item> item_table;
// current thread (if exists)
bool is_thread;
Thread thread;
std::vector<Thread> thread_tab;
// current ticket (if exists)
bool is_ticket;
Ticket ticket;
std::vector<Ticket> ticket_tab;
// if not empty means an address for redirecting to
std::string redirect_to;
// send header X-LIGHTTPD-send-file with path to a file
std::string x_sendfile;
// send as attachment (causing header: content-disposition: attachment)
bool send_as_attachment;
// for debugging
void PrintGetTable();
void PrintEnv();
void PrintIn();
void ClearPostFileTmp();
void Clear();
void Init();
bool IsParam(const char * param_name);
const std::string & ParamValue(const char * param_name); // returns empty string if there is no such a parameter
void SetCookie(const char * name, const char * value, tm * expires = 0);
void SetCookie(const char * name, long value, tm * expires = 0);
bool IsPostVar(const char * var);
std::string * PostVar(const char * var); // it can return null when there is no such a post variable
bool PostVar(const char * var, std::string & result);
bool AllPostVarEmpty(); // returning true if all post vars are empty
void ReadEnvVariables();
void CheckMethod();
void ReadParameters();
void Read();
void SendAll();
void SendNotify();
void SetConfig(Config * pconfig);
Config * config;
enum Header
bool CanUse(long user_id, const char * group_name);
void SendSessionCookie();
void CheckIE();
void CheckKonqueror();
void SendHeaders(bool compressing, Header header);
void AddDebugInfo();
void SendPage(bool compressing, const std::string & source_ref);
// used to set some env_* variables into it, when the server didn't set that variable
// it contains '\0'
const char char_empty;
// used in ParamValue(const char * param_name) when there is no such a param
const std::string str_empty;
PostMultiParser post_multi_parser;
const char * SetEnvVar(const char * var);
void StandardLog();
Compress compress;
AcceptEncodingParser accept_encoding_parser;
HTMLFilter html_filter;
// html after filtering
std::string clean_html;