--- parser3/src/main/pa_request.C 2001/04/11 07:44:15 1.110 +++ parser3/src/main/pa_request.C 2001/04/19 11:57:00 1.115 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.110 2001/04/11 07:44:15 paf Exp $ + $Id: pa_request.C,v 1.115 2001/04/19 11:57:00 paf Exp $ */ #include "pa_config_includes.h" @@ -22,7 +22,7 @@ #include "_file.h" #include "pa_globals.h" #include "pa_vint.h" -#include "pa_vmframe.h" +#include "pa_vmethod_frame.h" #include "pa_types.h" #include "pa_vtable.h" #include "_random.h" @@ -96,7 +96,7 @@ Request::Request(Pool& apool, all located classes become children of one another, composing class we name 'MAIN' - @test get read of setlocale + @test get rid of setlocale */ void Request::core(const char *root_auto_path, bool root_auto_fail, const char *site_auto_path, bool site_auto_fail, @@ -158,36 +158,30 @@ void Request::core(const char *root_auto // to the one beside requested file. // all assigned bases from upper dir { - /* /document/root */ - char *file_spec= - (char *)malloc(strlen(info.path_translated)+strlen(AUTO_FILE_NAME)+1); - size_t document_root_size=strlen(info.document_root); - if(info.document_root[document_root_size-1]=='/') - document_root_size--; - memcpy(file_spec, info.document_root, document_root_size); - - /* /requested/file.html */ - char *branches=(char *)malloc(strlen(info.path_translated)+1); - strcpy(branches, info.path_translated+document_root_size); - char *next=branches; - char *append_here=file_spec+document_root_size; - - size_t slash_auto_p_size=strlen("/" AUTO_FILE_NAME); - while(true) { - char *step=lsplit(&next, '/'); - if(next) { // not 'file.html' part - size_t step_size=strlen(step); - memcpy(append_here, step, step_size); - append_here+=step_size; - memcpy(append_here, "/" AUTO_FILE_NAME, slash_auto_p_size+1); - append_here++/* / */; - - String& sfile_spec=*NEW String(pool()); - sfile_spec.APPEND_CLEAN(file_spec, 0, "scanned", 0); - main_class=use_file(sfile_spec, false/*ignore read problem*/, - main_class_name, main_class); - } else - break; + Array ladder(pool()); + const char *after=info.path_translated; + size_t drlen=strlen(info.document_root); + if(memcmp(after, info.document_root, drlen)==0) { + after+=drlen; + if(after[-1]=='/') + --after; + } + + while(const char *before=strchr(after, '/')) { + String& step=*NEW String(pool()); + if(after!=info.path_translated) { + step.APPEND_CLEAN( + info.path_translated, before+1/* / */-info.path_translated, + "path-translated-scanned", ladder.size()); + step << AUTO_FILE_NAME; + ladder+=&step; + } + after=before+1; + } + for(int i=ladder.size(); --i>=0; ) { + const String& sfile_spec=*ladder.get_string(i); + main_class=use_file(sfile_spec, false/*ignore read problem*/, + main_class_name, main_class); } } @@ -283,7 +277,7 @@ void Request::core(const char *root_auto TRY { // log the beast const String *problem_source=e.problem_source(); - if(problem_source) + if(problem_source && problem_source->size()) SAPI::log(pool(), #ifndef NO_STRING_ORIGIN "%s(%d): " @@ -330,7 +324,7 @@ void Request::core(const char *root_auto // origin Value *origin_value=0; #ifndef NO_STRING_ORIGIN - if(problem_source) { + if(problem_source && problem_source->size()) { const Origin& origin=problem_source->origin(); if(origin.file) { char *buf=(char *)malloc(MAX_STRING); @@ -347,7 +341,7 @@ void Request::core(const char *root_auto // source Value *source_value=0; - if(problem_source) { + if(problem_source && problem_source->size()) { String& problem_source_copy=*NEW String(pool()); problem_source_copy.append(*problem_source, flang, true); @@ -473,19 +467,7 @@ VStateless_class *Request::use_buf(const return &cclass; } -/** - - fail_if_junction(true, junction = fail - - fail_if_junction(false, not junction = fail -*/ -void Request::fail_if_junction_(bool is, Value& value, - const String& method_name, const char *msg) { - - if((value.get_junction()!=0) ^ !is) - THROW(0, 0, - &method_name, - msg); -} - +/// @test with commandline start "parser3 a.html" so that ^load[a.cfg] worked! [now doesnt] const String& Request::relative(const char *apath, const String& relative_name) { int lpath_buf_size=strlen(apath)+1; char *lpath=(char *)malloc(lpath_buf_size); @@ -537,11 +519,12 @@ void Request::output_result(const VFile& } // content-disposition - if(VString *vfile_name=static_cast(body_file.fields().get(*name_name))) { - VHash& vhash=*NEW VHash(pool()); - vhash.hash().put(*content_disposition_filename_name, vfile_name); - response.fields().put(*content_disposition_name, &vhash); - } + if(VString *vfile_name=static_cast(body_file.fields().get(*name_name))) + if(vfile_name->string()!=NONAME_DAT) { + VHash& vhash=*NEW VHash(pool()); + vhash.hash().put(*content_disposition_filename_name, vfile_name); + response.fields().put(*content_disposition_name, &vhash); + } // prepare header: $response:fields without :body response.fields().for_each(add_header_attribute, /*excluding*/ body_name);