|
|
| version 1.245.2.37.2.32, 2003/04/11 16:05:43 | version 1.255, 2003/11/20 15:35:32 |
|---|---|
| Line 31 static const char* IDENT_REQUEST_C="$Dat | Line 31 static const char* IDENT_REQUEST_C="$Dat |
| #include "pa_vcookie.h" | #include "pa_vcookie.h" |
| #include "pa_vresponse.h" | #include "pa_vresponse.h" |
| #include "pa_vmemory.h" | #include "pa_vmemory.h" |
| #include "pa_vconsole.h" | |
| // consts | // consts |
| Line 51 const char* ORIGINS_CONTENT_TYPE="text/p | Line 52 const char* ORIGINS_CONTENT_TYPE="text/p |
| #define EXCEPTION_TYPE_PART_NAME "type" | #define EXCEPTION_TYPE_PART_NAME "type" |
| #define EXCEPTION_SOURCE_PART_NAME "source" | #define EXCEPTION_SOURCE_PART_NAME "source" |
| #define EXCEPTION_COMMENT_PART_NAME "comment" | #define EXCEPTION_COMMENT_PART_NAME "comment" |
| #define EXCEPTION_HANDLED_PART_NAME "handled" | |
| // globals | // globals |
| Line 94 VStateless_class& VClassMAIN_create(); | Line 94 VStateless_class& VClassMAIN_create(); |
| // | // |
| Request::Request(SAPI_Info& asapi_info, Request_info& arequest_info, | Request::Request(SAPI_Info& asapi_info, Request_info& arequest_info, |
| String::Language adefault_lang, bool status_allowed): | String::Language adefault_lang, bool status_allowed): |
| // private | // private |
| anti_endless_execute_recoursion(0), | anti_endless_execute_recoursion(0), |
| Line 132 Request::Request(SAPI_Info& asapi_info, | Line 132 Request::Request(SAPI_Info& asapi_info, |
| mime_types(0) | mime_types(0) |
| { | { |
| // file_no=0 => unknown | // file_no=0 => unknown |
| file_list+=StringBody("UNKNOWN"); | file_list+=String::Body("UNKNOWN"); |
| file_list+=StringBody("-body of process-"); // pseudo_file_no__process | file_list+=String::Body("-body of process-"); // pseudo_file_no__process |
| // maybe expire old caches | // maybe expire old caches |
| cache_managers.maybe_expire(); | cache_managers.maybe_expire(); |
| Line 147 Request::Request(SAPI_Info& asapi_info, | Line 147 Request::Request(SAPI_Info& asapi_info, |
| /// methodless | /// methodless |
| // env class | // env class |
| classes().put(StringBody(ENV_CLASS_NAME), new VEnv(asapi_info)); | classes().put(String::Body(ENV_CLASS_NAME), new VEnv(asapi_info)); |
| // status class | // status class |
| if(status_allowed) | if(status_allowed) |
| classes().put(StringBody(STATUS_CLASS_NAME), new VStatus()); | classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); |
| // request class | // request class |
| classes().put(StringBody(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets)); | classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets)); |
| // cookie class | // cookie class |
| classes().put(StringBody(COOKIE_CLASS_NAME), &cookie); | classes().put(String::Body(COOKIE_CLASS_NAME), &cookie); |
| // console class | |
| classes().put(String::Body(CONSOLE_CLASS_NAME), new VConsole()); | |
| /// methoded | /// methoded |
| // response class | // response class |
| Line 192 Value& Request::get_self() { return meth | Line 194 Value& Request::get_self() { return meth |
| static void load_charset(HashStringValue::key_type akey, | static void load_charset(HashStringValue::key_type akey, |
| HashStringValue::value_type avalue, | HashStringValue::value_type avalue, |
| Request_charsets* charsets) { | Request_charsets* charsets) { |
| const StringBody NAME=String(akey, String::L_CLEAN).change_case(charsets->source(), String::CC_UPPER); | const String::Body NAME=String(akey, String::L_CLEAN).change_case(charsets->source(), String::CC_UPPER); |
| ::charsets.load_charset(*charsets, NAME, avalue->as_string()); | ::charsets.load_charset(*charsets, NAME, avalue->as_string()); |
| } | } |
| void Request::configure_admin(VStateless_class& conf_class) { | void Request::configure_admin(VStateless_class& conf_class) { |
| Line 267 gettimeofday(&mt[0],NULL); | Line 269 gettimeofday(&mt[0],NULL); |
| --after; | --after; |
| } | } |
| int step=0; | |
| while(const char* before=strchr(after, '/')) { | while(const char* before=strchr(after, '/')) { |
| String& sfile_spec=*new String; | String& sfile_spec=*new String; |
| if(after!=request_info.path_translated) { | if(after!=request_info.path_translated) { |
| Line 332 gettimeofday(&mt[1],NULL); | Line 333 gettimeofday(&mt[1],NULL); |
| gettimeofday(&mt[2],NULL); | gettimeofday(&mt[2],NULL); |
| #endif | #endif |
| VString& body_vstring_before_post_process=*new VString(*body_string); | // extract response body |
| VString* body_vstring_after_post_process=&body_vstring_before_post_process; | Value* body_value=response.fields().get(download_name); // $response:download? |
| bool as_attachment=body_value!=0; | |
| if(!body_value) | |
| body_value=response.fields().get(body_name); // $response:body | |
| if(!body_value) | |
| body_value=new VString(*body_string); // just result of ^main[] | |
| // @postprocess | // @postprocess |
| if(Value* value=main_class.get_element(post_process_method_name, main_class, false)) | if(Value* value=main_class.get_element(post_process_method_name, main_class, false)) |
| if(Junction* junction=value->get_junction()) | if(Junction* junction=value->get_junction()) |
| Line 343 gettimeofday(&mt[2],NULL); | Line 350 gettimeofday(&mt[2],NULL); |
| VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); | VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); |
| frame.set_self(main_class); | frame.set_self(main_class); |
| frame.store_param(body_vstring_before_post_process); | frame.store_param(*body_value); |
| body_vstring_after_post_process= | body_value=&execute_method(frame, *method).as_value(); |
| new VString(execute_method(frame, *method)); | |
| } | } |
| VFile* body_file=body_vstring_after_post_process->as_vfile( | VFile* body_file=body_value->as_vfile( |
| String::L_UNSPECIFIED, &charsets); | String::L_UNSPECIFIED, &charsets); |
| // extract response body | |
| Value* body_value=response.fields().get(download_name); | |
| bool as_attachment=body_value!=0; | |
| if(!body_value) | |
| body_value=response.fields().get(body_name); | |
| if(body_value) // there is some $response:body | |
| body_file=body_value->as_vfile(String::L_UNSPECIFIED, &charsets); | |
| #ifdef RESOURCES_DEBUG | #ifdef RESOURCES_DEBUG |
| //measure:after postprocess | //measure:after postprocess |
| gettimeofday(&mt[3],NULL); | gettimeofday(&mt[3],NULL); |
| Line 456 Table::columns_type stack_trace_columns( | Line 453 Table::columns_type stack_trace_columns( |
| *stack_trace_columns+=new String("colno"); | *stack_trace_columns+=new String("colno"); |
| Table& stack_trace=*new Table(stack_trace_columns); | Table& stack_trace=*new Table(stack_trace_columns); |
| if(!exception_trace.is_empty()/*signed!*/) | if(!exception_trace.is_empty()/*signed!*/) |
| for(size_t i=exception_trace.bottom_index(); i<=exception_trace.top_index(); i++) { | for(size_t i=exception_trace.bottom_index(); i<exception_trace.top_index(); i++) { |
| Trace trace=exception_trace.get(i); | Trace trace=exception_trace.get(i); |
| Table::element_type row(new ArrayString); | Table::element_type row(new ArrayString); |
| Line 464 if(!exception_trace.is_empty()/*signed!* | Line 461 if(!exception_trace.is_empty()/*signed!* |
| Operation::Origin origin=trace.origin(); | Operation::Origin origin=trace.origin(); |
| if(origin.file_no) { | if(origin.file_no) { |
| *row+=new String(file_list[origin.file_no], String::L_TAINTED); // 'file' column | *row+=new String(file_list[origin.file_no], String::L_TAINTED); // 'file' column |
| *row+=new String(StringBody::Format(1+origin.line), String::L_CLEAN); // 'lineno' column | *row+=new String(String::Body::Format(1+origin.line), String::L_CLEAN); // 'lineno' column |
| *row+=new String(StringBody::Format(1+origin.col), String::L_CLEAN); // 'colno' column | *row+=new String(String::Body::Format(1+origin.col), String::L_CLEAN); // 'colno' column |
| } | } |
| stack_trace+=row; | stack_trace+=row; |
| } | } |
| Line 473 frame.store_param(*new VTable(&stack_tra | Line 470 frame.store_param(*new VTable(&stack_tra |
| // future $response:body= | // future $response:body= |
| // execute ^unhandled_exception[exception;stack] | // execute ^unhandled_exception[exception;stack] |
| body_string=&execute_method(frame, *method); | body_string=&execute_method(frame, *method).as_string(); |
| } | } |
| } | } |
| } | } |
| Line 518 body_string=&execute_method(frame, *meth | Line 515 body_string=&execute_method(frame, *meth |
| } | } |
| } | } |
| size_t Request::register_file(StringBody file_spec) { | size_t Request::register_file(String::Body file_spec) { |
| file_list+=file_spec; | file_list+=file_spec; |
| return file_list.count()-1; | return file_list.count()-1; |
| } | } |
| Line 615 const String& Request::absolute(const St | Line 612 const String& Request::absolute(const St |
| result << relative_name; | result << relative_name; |
| return result; | return result; |
| } else | } else |
| return relative_name.pos("://")==STRING_NOT_FOUND? | if(relative_name.pos("://")!=STRING_NOT_FOUND // something like "http://xxx" |
| relative(request_info.path_translated, relative_name) | #ifdef WIN32 |
| :relative_name; // something like "http://xxx" | || relative_name.pos(":")==1 // DRIVE: |
| || relative_name.starts_with("\\\\") // UNC1 | |
| || relative_name.starts_with("//") // UNC2 | |
| #endif | |
| ) | |
| return relative_name; | |
| else | |
| return relative(request_info.path_translated, relative_name); | |
| } | } |
| static void add_header_attribute( | static void add_header_attribute( |
| Line 708 GdomeDOMString_auto_ptr Request::transco | Line 712 GdomeDOMString_auto_ptr Request::transco |
| return charsets.source().transcode(s); | return charsets.source().transcode(s); |
| } | } |
| GdomeDOMString_auto_ptr Request::transcode(const StringBody s) { | GdomeDOMString_auto_ptr Request::transcode(const String::Body s) { |
| return charsets.source().transcode(s); | return charsets.source().transcode(s); |
| } | } |
| Line 760 Request::Exception_details Request::get_ | Line 764 Request::Exception_details Request::get_ |
| // $.file lineno colno | // $.file lineno colno |
| if(trace) { | if(trace) { |
| const Operation::Origin origin=trace.origin(); | const Operation::Origin origin=trace.origin(); |
| hash.put(StringBody("file"), | hash.put(String::Body("file"), |
| new VString(*new String(file_list[origin.file_no], String::L_TAINTED))); | new VString(*new String(file_list[origin.file_no], String::L_TAINTED))); |
| hash.put(StringBody("lineno"), new VInt(1+origin.line)); | hash.put(String::Body("lineno"), new VInt(1+origin.line)); |
| hash.put(StringBody("colno"), new VInt(1+origin.col)); | hash.put(String::Body("colno"), new VInt(1+origin.col)); |
| } | } |
| // $.comment | // $.comment |