--- parser3/src/main/pa_request.C 2001/10/30 15:08:20 1.173 +++ parser3/src/main/pa_request.C 2001/11/16 12:38:44 1.181 @@ -2,15 +2,13 @@ Parser: request class main part. @see compile.C and execute.C. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: pa_request.C,v 1.173 2001/10/30 15:08:20 paf Exp $ + $Id: pa_request.C,v 1.181 2001/11/16 12:38:44 paf Exp $ */ #include "pa_config_includes.h" -//#include "pcre.h" -//#include "internal.h" extern "C" unsigned char pcre_default_tables[]; // pcre/chartables.c #include "pa_sapi.h" @@ -26,6 +24,7 @@ extern "C" unsigned char pcre_default_ta #include "pa_vfile.h" #include "pa_dictionary.h" #include "pa_charset_manager.h" +#include "pa_charset_connection.h" /// content type of exception response, when no @MAIN:exception handler defined const char *UNHANDLED_EXCEPTION_CONTENT_TYPE="text/plain"; @@ -41,7 +40,8 @@ static void load_charset(const Hash::Key Value& value=*static_cast(avalue); Hash& CTYPE=*static_cast(info); - Charset_connection& connection=charset_manager->get_connection(akey, value.as_string()); + Charset_connection& connection= + charset_manager->get_connection(akey, value.as_string()); // charset->pcre_tables CTYPE.put(akey, connection.pcre_tables()); @@ -50,10 +50,12 @@ static void load_charset(const Hash::Key // Request::Request(Pool& apool, Info& ainfo, - String::Untaint_lang adefault_lang) : Pooled(apool), + String::Untaint_lang adefault_lang, + bool status_allowed) : Pooled(apool), stack(apool), OP(*MOP_create(apool)), env(apool), + status(apool), form(apool), math(apool), request(apool, *this), @@ -73,6 +75,9 @@ Request::Request(Pool& apool, anti_endless_execute_recoursion(0), trace(apool) { + // maybe expire old caches + cache_managers->maybe_expire(); + /// directly used // operators OP.register_directly_used(*this); @@ -83,6 +88,9 @@ Request::Request(Pool& apool, /// methodless // env class classes().put(*NEW String(pool(), ENV_CLASS_NAME), &env); + // status class + if(status_allowed) + classes().put(*NEW String(pool(), STATUS_CLASS_NAME), &status); // request class classes().put(*NEW String(pool(), REQUEST_CLASS_NAME), &request); // cookie class @@ -106,12 +114,14 @@ Request::Request(Pool& apool, the file user requested us to process all located classes become children of one another, composing class we name 'MAIN' + + @test log stack trace + */ void Request::core( const char *root_config_filespec, bool root_config_fail_on_read_problem, const char *site_config_filespec, bool site_config_fail_on_read_problem, bool header_only) { - //_asm { int 3 } try { char *auto_filespec=(char *)malloc(MAX_STRING); @@ -207,10 +217,6 @@ void Request::core( if(Value *vcharset=(Value *)hash->get(*charset_name)) pool().set_charset(vcharset->as_string()); - if(Value *element=main_class->get_element(*user_html_name)) - if(Table *table=element->get_table()) - pool().set_tag(NEW Dictionary(*table)); - // $MAIN:MIME-TYPES if(Value *element=main_class->get_element(*mime_types_name)) if(Table *table=element->get_table()) @@ -272,7 +278,7 @@ void Request::core( if(problem_source && problem_source->size()) SAPI::log(pool(), #ifndef NO_STRING_ORIGIN - "%s(%d): " + ORIGIN_FILE_LINE_FORMAT": " #endif "'%s' %s [%s %s]", #ifndef NO_STRING_ORIGIN @@ -290,14 +296,10 @@ void Request::core( e.comment(), e.type()?e.type()->cstr():"-", e.code()?e.code()->cstr():"-" - ); - - /// @test log stack trace + ); // reset language to default flang=fdefault_lang; - if(flang==String::UL_USER_HTML) - flang=String::UL_HTML; // no _ & Co conversions in @exception[params] // reset response response.fields().clear(); @@ -324,7 +326,7 @@ void Request::core( const Origin& origin=problem_source->origin(); if(origin.file) { char *buf=(char *)malloc(MAX_STRING); - size_t buf_size=snprintf(buf, MAX_STRING, "%s(%d)", + size_t buf_size=snprintf(buf, MAX_STRING, ORIGIN_FILE_LINE_FORMAT, origin.file, 1+origin.line); origin_value=NEW VString(*NEW String(pool(), buf, buf_size, true)); @@ -386,7 +388,7 @@ void Request::core( const Origin& origin=name->origin(); if(origin.file) { char *buf=(char *)malloc(MAX_STRING); - size_t buf_size=snprintf(buf, MAX_STRING, "%s(%d)", + size_t buf_size=snprintf(buf, MAX_STRING, ORIGIN_FILE_LINE_FORMAT, origin.file, 1+origin.line); row+=NEW String(pool(), buf, buf_size, true); // origin column } @@ -413,8 +415,10 @@ void Request::core( #ifndef NO_STRING_ORIGIN const Origin& origin=problem_source->origin(); if(origin.file) - printed+=snprintf(buf+printed, MAX_STRING-printed, "%s(%d): ", - origin.file, 1+origin.line); + printed+=snprintf(buf+printed, MAX_STRING-printed, + ORIGIN_FILE_LINE_FORMAT": ", + origin.file, 1+origin.line + ); #endif printed+=snprintf(buf+printed, MAX_STRING-printed, "'%s' ", problem_source->cstr()); @@ -532,8 +536,8 @@ const String& Request::absolute(const St static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, void *info) { - String *attribute_to_exclude=static_cast(info); - if(aattribute==*attribute_to_exclude) + Request& r=*static_cast(info); + if(aattribute==*body_name) return; Value& lmeaning=*static_cast(ameaning); @@ -563,12 +567,12 @@ void Request::output_result(const VFile& 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); + vhash.hash(0).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); + response.fields().for_each(add_header_attribute, this); // prepare... const void *body=body_file.value_ptr();