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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#ifndef headerfilecmslucorerequest
|
|
|
|
#define headerfilecmslucorerequest
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#include <fcgiapp.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
2008-12-30 02:05:03 +01:00
|
|
|
#include <iomanip>
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
#include "requesttypes.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "item.h"
|
|
|
|
#include "error.h"
|
2009-09-22 01:05:05 +02:00
|
|
|
#include "compress.h"
|
2009-10-08 19:59:10 +02:00
|
|
|
#include "acceptencodingparser.h"
|
2009-12-09 01:42:40 +01:00
|
|
|
#include "htmlfilter.h"
|
2010-01-06 20:17:53 +01:00
|
|
|
#include "postmultiparser.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "config.h"
|
2008-12-10 05:42:49 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
FCGX_Stream * in, * out, * err;
|
|
|
|
FCGX_ParamArray env; // defined as 'char **'
|
|
|
|
|
|
|
|
|
|
|
|
enum Method { get, post, 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-08-10 22:43:38 +02:00
|
|
|
std::ostringstream headers, 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-10 05:42:49 +01:00
|
|
|
// current session
|
|
|
|
Session * session;
|
|
|
|
|
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-10 22:43:38 +02:00
|
|
|
// 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;
|
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
// last notify
|
|
|
|
int notify_code;
|
|
|
|
|
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
|
|
|
|
std::string redirect_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
|
|
|
|
std::string x_sendfile;
|
|
|
|
|
|
|
|
// send as attachment (causing header: content-disposition: attachment)
|
|
|
|
bool send_as_attachment;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// for debugging
|
2010-08-10 22:43:38 +02:00
|
|
|
void PrintGetTab();
|
2008-12-10 05:42:49 +01:00
|
|
|
void PrintEnv();
|
|
|
|
void PrintIn();
|
|
|
|
|
|
|
|
Request();
|
2010-01-06 20:17:53 +01:00
|
|
|
void ClearPostFileTmp();
|
2008-12-10 05:42:49 +01:00
|
|
|
void Clear();
|
|
|
|
|
2009-09-22 01:05:05 +02:00
|
|
|
void Init();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-07-04 22:27:14 +02:00
|
|
|
bool IsParam(const char * param_name);
|
|
|
|
const std::string & ParamValue(const char * 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
|
|
|
|
|
|
|
bool IsPostVar(const char * var);
|
2009-11-17 02:04:01 +01:00
|
|
|
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);
|
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 ReadEnvVariables();
|
|
|
|
void CheckMethod();
|
|
|
|
void ReadParameters();
|
|
|
|
void Read();
|
|
|
|
void SendAll();
|
2010-08-10 22:43:38 +02:00
|
|
|
//void SendNotify();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void SetConfig(Config * pconfig);
|
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;
|
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
enum Header
|
|
|
|
{
|
|
|
|
h_200,
|
|
|
|
h_404,
|
|
|
|
h_403
|
|
|
|
};
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
void SendSessionCookie();
|
2009-10-08 19:59:10 +02:00
|
|
|
void CheckIE();
|
2009-12-19 20:46:15 +01:00
|
|
|
void CheckKonqueror();
|
2009-10-08 19:59:10 +02:00
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
void SendHeaders(bool compressing, Header header);
|
2009-12-09 01:42:40 +01:00
|
|
|
void AddDebugInfo();
|
2010-01-11 15:47:52 +01:00
|
|
|
void SendPage(bool compressing, const std::string & source_ref);
|
2009-12-09 01:42:40 +01:00
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
// used to set some env_* variables into it, when the server didn't set that variable
|
|
|
|
// it contains '\0'
|
|
|
|
const char char_empty;
|
2009-11-17 00:36:38 +01:00
|
|
|
|
2010-07-04 22:27:14 +02:00
|
|
|
// used in ParamValue(const char * param_name) when there is no such a param
|
|
|
|
const std::string str_empty;
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
PostMultiParser post_multi_parser;
|
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
const char * SetEnvVar(const char * var);
|
2008-12-30 02:05:03 +01:00
|
|
|
void StandardLog();
|
|
|
|
|
2009-09-22 01:05:05 +02:00
|
|
|
Compress compress;
|
2009-10-08 19:59:10 +02:00
|
|
|
AcceptEncodingParser accept_encoding_parser;
|
2009-12-09 01:42:40 +01:00
|
|
|
HTMLFilter html_filter;
|
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2009-12-09 01:42:40 +01:00
|
|
|
// html after filtering
|
|
|
|
std::string clean_html;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
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
|