--- parser3/src/main/pa_request.C 2001/11/05 11:46:28 1.176 +++ parser3/src/main/pa_request.C 2001/11/16 12:38:44 1.181 @@ -4,13 +4,11 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: pa_request.C,v 1.176 2001/11/05 11:46:28 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,7 +50,8 @@ 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), @@ -74,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); @@ -85,7 +89,8 @@ Request::Request(Pool& apool, // env class classes().put(*NEW String(pool(), ENV_CLASS_NAME), &env); // status class - classes().put(*NEW String(pool(), STATUS_CLASS_NAME), &status); + 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 @@ -109,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); @@ -210,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()) @@ -275,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 @@ -293,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(); @@ -327,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)); @@ -389,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 } @@ -416,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()); @@ -535,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); @@ -571,7 +572,7 @@ void Request::output_result(const VFile& } // 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();