--- parser3/src/main/pa_request.C 2003/04/11 08:45:51 1.245.2.37.2.31 +++ parser3/src/main/pa_request.C 2003/11/19 11:00:33 1.254 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_REQUEST_C="$Date: 2003/04/11 08:45:51 $"; +static const char* IDENT_REQUEST_C="$Date: 2003/11/19 11:00:33 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -31,6 +31,7 @@ static const char* IDENT_REQUEST_C="$Dat #include "pa_vcookie.h" #include "pa_vresponse.h" #include "pa_vmemory.h" +#include "pa_vconsole.h" // consts @@ -51,7 +52,6 @@ const char* ORIGINS_CONTENT_TYPE="text/p #define EXCEPTION_TYPE_PART_NAME "type" #define EXCEPTION_SOURCE_PART_NAME "source" #define EXCEPTION_COMMENT_PART_NAME "comment" -#define EXCEPTION_HANDLED_PART_NAME "handled" // globals @@ -94,7 +94,7 @@ VStateless_class& VClassMAIN_create(); // 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 anti_endless_execute_recoursion(0), @@ -132,8 +132,8 @@ Request::Request(SAPI_Info& asapi_info, mime_types(0) { // file_no=0 => unknown - file_list+=StringBody("UNKNOWN"); - file_list+=StringBody("-body of process-"); // pseudo_file_no__process + file_list+=String::Body("UNKNOWN"); + file_list+=String::Body("-body of process-"); // pseudo_file_no__process // maybe expire old caches cache_managers.maybe_expire(); @@ -147,14 +147,16 @@ Request::Request(SAPI_Info& asapi_info, /// methodless // 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 if(status_allowed) - classes().put(StringBody(STATUS_CLASS_NAME), new VStatus()); + classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); // 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 - 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 // response class @@ -192,7 +194,7 @@ Value& Request::get_self() { return meth static void load_charset(HashStringValue::key_type akey, HashStringValue::value_type avalue, 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()); } void Request::configure_admin(VStateless_class& conf_class) { @@ -332,8 +334,14 @@ gettimeofday(&mt[1],NULL); gettimeofday(&mt[2],NULL); #endif - VString& body_vstring_before_post_process=*new VString(*body_string); - VString* body_vstring_after_post_process=&body_vstring_before_post_process; + // extract response body + 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 if(Value* value=main_class.get_element(post_process_method_name, main_class, false)) if(Junction* junction=value->get_junction()) @@ -343,23 +351,13 @@ gettimeofday(&mt[2],NULL); VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); frame.set_self(main_class); - frame.store_param(body_vstring_before_post_process); - body_vstring_after_post_process= - new VString(execute_method(frame, *method)); + frame.store_param(*body_value); + body_value=&execute_method(frame, *method).as_value(); } - VFile* body_file=body_vstring_after_post_process->as_vfile( + VFile* body_file=body_value->as_vfile( 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 //measure:after postprocess gettimeofday(&mt[3],NULL); @@ -456,7 +454,7 @@ Table::columns_type stack_trace_columns( *stack_trace_columns+=new String("colno"); Table& stack_trace=*new Table(stack_trace_columns); 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(); ilocate(0, sext.change_case(charsets.source(), String::CC_LOWER))) + Table::Action_options options; + if(mime_types->locate(0, sext.change_case(charsets.source(), String::CC_LOWER), options)) if(const String* result=mime_types->item(1)) return *result; else @@ -707,7 +713,7 @@ GdomeDOMString_auto_ptr Request::transco 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); } @@ -759,10 +765,10 @@ Request::Exception_details Request::get_ // $.file lineno colno if(trace) { 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))); - hash.put(StringBody("lineno"), new VInt(1+origin.line)); - hash.put(StringBody("colno"), new VInt(1+origin.col)); + hash.put(String::Body("lineno"), new VInt(1+origin.line)); + hash.put(String::Body("colno"), new VInt(1+origin.col)); } // $.comment