--- parser3/src/include/pa_request.h 2002/10/14 15:22:41 1.154 +++ parser3/src/include/pa_request.h 2003/01/29 11:06:43 1.160.2.4 @@ -1,14 +1,14 @@ /** @file Parser: request class decl. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_REQUEST_H #define PA_REQUEST_H -static const char* IDENT_REQUEST_H="$Date: 2002/10/14 15:22:41 $"; +static const char* IDENT_REQUEST_H="$Date: 2003/01/29 11:06:43 $"; #include "pa_pool.h" #include "pa_hash.h" @@ -55,35 +55,38 @@ class Temp_lang; class Methoded; class VMethodFrame; +/// some information from web server +class Info { +public: + const char *document_root; + const char *path_translated; + const char *method; + const char *query_string; + const char *uri; + const char *content_type; + size_t content_length; + const char *cookie; + bool mail_received; +}; + /// Main workhorse. class Request : public Pooled { friend class Temp_lang; friend class Temp_connection; friend class Request_context_saver; + friend class Temp_request_self; public: + Pool& pool() { return fpool; } + #ifdef RESOURCES_DEBUG /// measures double sql_connect_time; double sql_request_time; #endif - /// some information from web server - class Info { - public: - const char *document_root; - const char *path_translated; - const char *method; - const char *query_string; - const char *uri; - const char *content_type; - size_t content_length; - const char *cookie; - bool mail_received; - }; - - Request(Pool& apool, - Info& ainfo, + Request( + Request_info& ainfo, uchar adefault_lang, ///< all tainted data default untainting lang bool status_allowed ///< status class allowed ); @@ -215,12 +218,16 @@ public: bool origins_mode(); + void interrupt() { finterrupted=true; } + bool interrupted() { return finterrupted; } + public: /// info from web server - Info& info; - /// user's post data - const char *post_data; size_t post_size; + Request_info& info; + + /// source, client, mail charsets + Request_charsets charset_info; /// name of 'main' method const String main_method_name; @@ -249,13 +256,14 @@ public: private: + Pool fpool; + //@{ request processing status /// exception stack trace Stack exception_trace; /// execution stack Stack stack; /// contexts - Value *self; VMethodFrame *method_frame; Value *rcontext; WContext *wcontext; @@ -264,11 +272,13 @@ private: /// current connection SQL_Connection *fconnection; //@} + /// interrupted flag, raised on signals [SIGPIPE] + bool finterrupted; public: // status read methods - Value *get_self() { return self; } VMethodFrame *get_method_frame() { return method_frame; } + Value *get_self(); private: // core data @@ -310,8 +320,7 @@ private: // execute.C /// for @main[] const String *execute_virtual_method(Value& aself, const String& method_name); - Value *get_element(const String *& remember_name, - bool can_call_operator, bool should_explode_junction=false/*there's only one place when true*/); + Value *get_element(const String *& remember_name, bool can_call_operator); private: // defaults @@ -347,7 +356,7 @@ private: // connection manipulation private: - void output_result(const VFile& body_file, bool header_only); + void output_result(const VFile& body_file, bool header_only, bool as_attachment); }; /// Auto-object used to save request context across ^try body @@ -359,7 +368,6 @@ class Request_context_saver { /// execution stack int stack; /// contexts - Value *self; VMethodFrame *method_frame; Value *rcontext; WContext *wcontext; @@ -372,7 +380,6 @@ public: Request_context_saver(Request& ar) : exception_trace(ar.exception_trace.top_index()), stack(ar.stack.top_index()), - self(ar.self), method_frame(ar.method_frame), rcontext(ar.rcontext), wcontext(ar.wcontext), @@ -382,7 +389,7 @@ public: void restore() { fr.exception_trace.top_index(exception_trace); fr.stack.top_index(stack); - fr.self=self; fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; + fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; fr.flang=flang; fr.fconnection=fconnection; }