--- parser3/src/main/pa_request.C 2002/04/29 05:59:33 1.205 +++ parser3/src/main/pa_request.C 2002/05/07 07:39:19 1.207 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_request.C,v 1.205 2002/04/29 05:59:33 paf Exp $ + $Id: pa_request.C,v 1.207 2002/05/07 07:39:19 paf Exp $ */ #include "pa_sapi.h" @@ -22,6 +22,9 @@ #include "pa_charsets.h" #include "pa_charset.h" +const char *POST_PROCESS_METHOD_NAME="postprocess"; +const char *UNHANDLED_EXCEPTION_METHOD_NAME="unhandled_exception"; + /// content type of exception response, when no @MAIN:exception handler defined const char *UNHANDLED_EXCEPTION_CONTENT_TYPE="text/plain"; @@ -43,6 +46,7 @@ Request::Request(Pool& apool, Info& ainfo, uchar adefault_lang, bool status_allowed) : Pooled(apool), + main_method_name(apool, MAIN_METHOD_NAME), stack(apool), OP(*MOP_create(apool)), env(apool), @@ -238,7 +242,7 @@ gettimeofday(&mt[0],NULL); gettimeofday(&mt[1],NULL); #endif // execute @main[] - const String *body_string=execute_virtual_method(*main_class, *main_method_name); + const String *body_string=execute_virtual_method(*main_class, main_method_name); if(!body_string) throw Exception("parser.runtime", 0, @@ -252,7 +256,7 @@ gettimeofday(&mt[2],NULL); VString body_vstring_before_post_process(*body_string); VString *body_vstring_after_post_process=&body_vstring_before_post_process; // @postprocess - if(Value *value=main_class->get_element(*post_process_method_name)) + if(Value *value=main_class->get_element(*NEW String(pool(), POST_PROCESS_METHOD_NAME))) if(Junction *junction=value->get_junction()) if(const Method *method=junction->method) { // preparing to pass parameters to @@ -323,15 +327,14 @@ t[9]-t[3] #endif problem_source->cstr(), e.comment(), - e.type()?e.type():"-" + e.type() ); else SAPI::log(pool(), "%s: " "%s [%s]", info.uri, - e.comment(), - e.type()?e.type():"-" + e.comment(), e.type() ); // reset language to default @@ -346,7 +349,8 @@ t[9]-t[3] if(main_class) { // we've managed to end up with some main_class // maybe we'd be lucky enough as to report an error // in a gracefull way... - if(Value *value=main_class->get_element(*unhandled_exception_method_name)) + if(Value *value=main_class->get_element( + *NEW String(pool(), UNHANDLED_EXCEPTION_METHOD_NAME))) if(Junction *junction=value->get_junction()) if(const Method *method=junction->method) { // preparing to pass parameters to @@ -405,9 +409,9 @@ t[9]-t[3] printed+=snprintf(buf+printed, MAX_STRING-printed, "'%s' ", problem_source->cstr()); } - printed+=snprintf(buf+printed, MAX_STRING-printed, "%s", - e.comment()); - if(const char *type=e.type()) + if(const char *comment=e.comment(true)) + printed+=snprintf(buf+printed, MAX_STRING-printed, "%s", comment); + if(const char *type=e.type(true)) printed+=snprintf(buf+printed, MAX_STRING-printed, " type: %s", type); // future $response:content-type