--- parser3/src/main/pa_request.C 2013/07/23 14:29:02 1.333 +++ parser3/src/main/pa_request.C 2015/04/06 22:27:26 1.341 @@ -32,7 +32,7 @@ #include "pa_vconsole.h" #include "pa_vdate.h" -volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.333 2013/07/23 14:29:02 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; +volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.341 2015/04/06 22:27:26 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; // consts @@ -102,9 +102,9 @@ Request::Request(SAPI_Info& asapi_info, String::Language adefault_lang): // private anti_endless_execute_recoursion(0), - anti_endless_json_string_recoursion(0), // public + allow_class_replace(false), method_frame(0), rcontext(0), wcontext(0), @@ -156,7 +156,7 @@ Request::Request(SAPI_Info& asapi_info, // status class classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); // request class - classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets, form)); + classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets, form, asapi_info)); // cookie class classes().put(String::Body(COOKIE_CLASS_NAME), &cookie); // console class @@ -187,7 +187,7 @@ Request::~Request() { // if for some strange reason xml generic errors failed to be reported, free them up if(const char* xml_generic_errors=xmlGenericErrors()) { SAPI::log(sapi_info, "warning: unreported xmlGenericErrors: %s", xml_generic_errors); - free((void *)xml_generic_errors); + pa_free((void *)xml_generic_errors); } #endif } @@ -327,9 +327,6 @@ void Request::configure() { */ void Request::core(const char* config_filespec, bool config_fail_on_read_problem, bool header_only) { try { - // filling mail received - mail.fill_received(*this); - // loading config if(config_filespec) { const String& filespec=*new String(config_filespec); @@ -339,6 +336,9 @@ void Request::core(const char* config_fi true /*file must exist if 'fail on read problem' not set*/); } + // filling mail received + mail.fill_received(*this); + // loading auto.p files from document_root/.. // to the one beside requested file. // all assigned bases from upper dir @@ -385,7 +385,7 @@ void Request::core(const char* config_fi if(!body_string) throw Exception(PARSER_RUNTIME, 0, - "'"MAIN_METHOD_NAME"' method not found"); + "'" MAIN_METHOD_NAME "' method not found"); // extract response body Value* body_value=response.fields().get(download_name); // $response:download? @@ -614,11 +614,13 @@ void Request::use_buf(VStateless_class& execute_nonvirtual_method(cclass, auto_method_name, vfilespec, false/*no result needed*/); + + cclass.enable_default_setter(); } } const String& Request::relative(const char* apath, const String& relative_name) { - char *hpath=strdup(apath); + char *hpath=pa_strdup(apath); String& result=*new String; if(rsplit(hpath, '/')) // if something/splitted result << hpath << "/"; @@ -628,7 +630,7 @@ const String& Request::relative(const ch const String& Request::absolute(const String& relative_name) { if(relative_name.first_char()=='/') { - String& result=*new String(strdup(request_info.document_root)); + String& result=*new String(pa_strdup(request_info.document_root)); result << relative_name; return result; } else @@ -735,7 +737,7 @@ static void output_pieces(Request& r, const size_t BUFSIZE = 10*0x400; char buf[BUFSIZE]; - const char *range = SAPI::get_env(r.sapi_info, "HTTP_RANGE"); + const char *range = SAPI::Env::get(r.sapi_info, "HTTP_RANGE"); size_t offset=0; size_t part_length=content_length; if(range){ @@ -982,3 +984,19 @@ Request::Exception_details Request::get_ return Request::Exception_details(trace, problem_source, vhash); } + +Temp_value_element::Temp_value_element(Request& arequest, Value& awhere, const String& aname, Value* awhat) : + frequest(arequest), + fwhere(awhere), + fname(aname), + saved(awhere.get_element(aname)) +{ + Junction* junction; + if(saved && (junction=saved->get_junction()) && junction->is_getter) + saved=0; + frequest.put_element(fwhere, aname, awhat); +} + +Temp_value_element::~Temp_value_element() { + frequest.put_element(fwhere, fname, saved ? saved : VVoid::get()); +}