164 lines
3.6 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 "requesttypes.h"
#include "session.h"
#include "item.h"
#include "error.h"
#include "config.h"
#include "textstream.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 **'
// !! moze pozbyc sie tego none?
enum Method { get, post, head, none } method;
enum Role { responder, authorizer } role;
// headers, page and debug
//std::ostringstream headers, page, debug;
TextStream<std::string> headers;
TextStream<std::wstring> page, debug;
// raw parameters
GetTab get_tab;
PostTab post_tab;
PostFileTab post_file_tab;
CookieTab cookie_tab;
// 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
Session * session;
// current directory
std::vector<Item*> dir_tab;
// true if a file exists
bool is_item;
// current file (if exists)
Item item;
// current winix function
// null if there is no a function
FunctionBase * function;
// parameters (name:value)
ParamTab param_tab;
// request status
Error status;
// last notify
int notify_code;
// usually items in the current directory (depends on the function)
std::vector<Item> item_tab;
// if not empty means an address for redirecting to
std::wstring redirect_to;
std::string aredirect_to;
// send header X-LIGHTTPD-send-file with path to a file
std::wstring x_sendfile;
// send as attachment (causing header: content-disposition: attachment)
bool send_as_attachment;
// this is a pointer either to the item (if exists) or to the last directory
Item * last_item;
void SetConfig(Config * pconfig);
void Clear();
// for debugging
void PrintGetTab();
void PrintEnv();
bool IsParam(const wchar_t * param_name);
bool IsParam(const std::wstring & param_name);
const std::wstring & ParamValue(const wchar_t * 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 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);
bool AllPostVarEmpty(); // returning true if all post vars are empty
void SendAll();
Config * config;
void ClearPostFileTmp();
// contains '\0'
// used to set env_* pointers to the empty value
const char char_empty;
// used in ParamValue() and PostVar() when there is no such a param
const std::wstring str_empty;