--- parser3/src/main/pa_request.C 2010/05/20 04:36:20 1.318 +++ parser3/src/main/pa_request.C 2011/11/11 23:36:04 1.327 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2010/05/20 04:36:20 $"; +static const char * const IDENT_REQUEST_C="$Date: 2011/11/11 23:36:04 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -97,9 +97,10 @@ 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): // private anti_endless_execute_recoursion(0), + anti_endless_json_string_recoursion(0), // public method_frame(0), @@ -157,8 +158,7 @@ Request::Request(SAPI_Info& asapi_info, // env class classes().put(String::Body(ENV_CLASS_NAME), new VEnv(asapi_info)); // status class - if(status_allowed) - classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); + classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); // request class classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets, form)); // cookie class @@ -205,12 +205,11 @@ Value* Request::get_class(const String& if(Junction* junction=value->get_junction()) if(const Method *method=junction->method) { Value *vname=new VString(name); - VMethodFrame frame(*junction, 0/*no parent*/); + VMethodFrame frame(*method, 0 /*no parent*/, main_class); - frame.set_self(main_class); frame.store_params(&vname, 1); // we don't need the result - execute_method(frame, *method); + execute_method(frame); result=classes().get(name); } @@ -409,11 +408,12 @@ gettimeofday(&mt[2],NULL); if(const Method *method=junction->method) { // preparing to pass parameters to // @postprocess[data] - VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); - frame.set_self(main_class); + VMethodFrame frame(*method, 0 /*no parent*/, main_class); frame.store_params(&body_value, 1); - body_value=&execute_method(frame, *method).as_value(); + execute_method(frame); + + body_value=&frame.result().as_value(); } VFile* body_file=body_value->as_vfile(flang, &charsets); @@ -467,8 +467,6 @@ t[9]-t[3] if(const Method *method=junction->method) { // preparing to pass parameters to // @unhandled_exception[exception;stack] - VMethodFrame frame(/*method->name, */ *junction, 0/*no caller*/); - frame.set_self(main_class); // $stack[^table::create{name file lineno colno}] Table::columns_type stack_trace_columns(new ArrayString); @@ -492,13 +490,17 @@ t[9]-t[3] stack_trace+=row; } - Value *params[]={&details.vhash, new VTable(&stack_trace)}; - frame.store_params(params, 2); - // future $response:body= // execute ^unhandled_exception[exception;stack] exception_trace.clear(); // forget all about previous life, in case there would be error inside of this method, error handled would not be mislead by old stack contents (see extract_origin) - body_string=&execute_method(frame, *method).as_string(); + + VMethodFrame frame(*method, 0 /*no caller*/, main_class); + Value *params[]={&details.vhash, new VTable(&stack_trace)}; + + frame.store_params(params, 2); + execute_method(frame); + + body_string=&frame.result().as_string(); } } } @@ -566,6 +568,11 @@ void Request::use_file(VStateless_class& const String& file_name, const String* use_filespec/*absolute*/) { + if(file_name.is_empty()) + throw Exception(PARSER_RUNTIME, + 0, + "usage failed - no filename was specified"); + const String* filespec=0; if(file_name.first_char()=='/') //absolute path? [no need to scan MAIN:CLASS_PATH] @@ -844,7 +851,7 @@ void Request::output_result(VFile* body_ name_cstr=after_slash; if(char *after_slash=rsplit(name_cstr, '/')) name_cstr=after_slash; - vfile_name=new VString(*new String(name_cstr)); + vfile_name=new VString(*new String(name_cstr)); } } if(vfile_name) { @@ -853,7 +860,7 @@ void Request::output_result(VFile* body_ VHash& hash=*new VHash(); HashStringValue &h=hash.hash(); h.put(value_name, new VString( as_attachment ? content_disposition_attachment : content_disposition_inline )); - h.put(content_disposition_filename_name, vfile_name); + h.put(content_disposition_filename_name, new VString(String(sfile_name, String::L_HTTP_HEADER))); response.fields().put(content_disposition, &hash); @@ -926,12 +933,6 @@ const String& Request::mime_type_of(cons return *new String("application/octet-stream"); } -const String* Request::get_method_filename(const Method* method){ - if(ArrayOperation* code=method->parser_code) - return get_used_filename(code->get(1).origin.file_no); // todo@ check if 1 is always origin - return 0; -} - const String* Request::get_used_filename(uint file_no){ if(file_no < file_list.count()) return new String(file_list[file_no], String::L_TAINTED);