--- parser3/src/main/pa_request.C 2003/03/21 16:16:44 1.245.2.37.2.8 +++ parser3/src/main/pa_request.C 2003/03/26 07:45:24 1.245.2.37.2.17 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_REQUEST_C="$Date: 2003/03/21 16:16:44 $"; +static const char* IDENT_REQUEST_C="$Date: 2003/03/26 07:45:24 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -30,6 +30,7 @@ static const char* IDENT_REQUEST_C="$Dat #include "pa_vform.h" #include "pa_vcookie.h" #include "pa_vresponse.h" +#include "pa_vmemory.h" // consts @@ -81,7 +82,7 @@ static const String class_path_name(CLAS // defines // op.C -VStateless_class* VClassMAIN_create(); +VStateless_class& VClassMAIN_create(); // op.C VHash& exception2vhash(const Exception& e); @@ -110,7 +111,7 @@ Request::Request(SAPI_Info& asapi_info, request_info(arequest_info), charsets(UTF8_charset, UTF8_charset, UTF8_charset), // default charsets - main_class(*VClassMAIN_create()), + main_class(VClassMAIN_create()), form(*new VForm), mail(*new VMail), response(*new VResponse(arequest_info, charsets)), @@ -136,14 +137,14 @@ Request::Request(SAPI_Info& asapi_info, /// methodless // env class - classes().put(*new StringBody(ENV_CLASS_NAME), new VEnv(asapi_info)); + classes().put(StringBody(ENV_CLASS_NAME), new VEnv(asapi_info)); // status class if(status_allowed) - classes().put(*new StringBody(STATUS_CLASS_NAME), new VStatus()); + classes().put(StringBody(STATUS_CLASS_NAME), new VStatus()); // request class - classes().put(*new StringBody(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets)); + classes().put(StringBody(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets)); // cookie class - classes().put(*new StringBody(COOKIE_CLASS_NAME), &cookie); + classes().put(StringBody(COOKIE_CLASS_NAME), &cookie); /// methoded // response class @@ -159,6 +160,11 @@ Request::Request(SAPI_Info& asapi_info, Value& math=*new VMath; classes().put(math.get_class()->base_class()->name(), &math); } + // memory class + { + Value& memory=*new VMemory; + classes().put(memory.get_class()->base_class()->name(), &memory); + } } Request::~Request() { @@ -324,7 +330,7 @@ gettimeofday(&mt[2],NULL); } VFile* body_file=body_vstring_after_post_process->as_vfile( - String::L_UNSPECIFIED); + String::L_UNSPECIFIED, &charsets); // extract response body Value* body_value=response.fields().get(download_name); @@ -333,7 +339,7 @@ gettimeofday(&mt[2],NULL); body_value=response.fields().get(body_name); if(body_value) // there is some $response:body - body_file=body_value->as_vfile(); + body_file=body_value->as_vfile(String::L_UNSPECIFIED, &charsets); #ifdef RESOURCES_DEBUG //measure:after postprocess @@ -421,8 +427,8 @@ t[9]-t[3] #ifndef NO_STRING_ORIGIN const String_fragment::Origin& origin=name->origin(); if(origin.file) { - *row+=*new StringBody(origin.file, 0, true)); // file column - *row+=*new StringBody( + *row+=StringBody(origin.file, 0, true)); // file column + *row+=StringBody( pool().format_integer(1+origin.line), 0, true)); // line column } @@ -442,7 +448,7 @@ t[9]-t[3] // doing that ugly // make up result: $origin $source $comment $type $code - char *buf=new char[MAX_STRING]; + char *buf=new(PointerFreeGC) char[MAX_STRING]; size_t printed=0; if(const String* problem_source=e.problem_source()) { /*const String_fragment::Origin& origin=problem_source->origin(); @@ -468,7 +474,7 @@ t[9]-t[3] } VString body_vstring(*body_string); - VFile* body_file=body_vstring.as_vfile(); + VFile* body_file=body_vstring.as_vfile(String::L_UNSPECIFIED, &charsets); // ERROR. write it out output_result(body_file, header_only, false); @@ -567,7 +573,8 @@ const String& Request::absolute(const St result << relative_name; return result; } else - return relative_name.pos("://")<0? relative(request_info.path_translated, relative_name) + return relative_name.pos("://")==STRING_NOT_FOUND? + relative(request_info.path_translated, relative_name) :relative_name; // something like "http://xxx" } @@ -582,7 +589,7 @@ static void add_header_attribute( SAPI::add_header_attribute(r->sapi_info, aattribute.cstr(), - attributed_meaning_to_string(ameaning, String::L_HTTP_HEADER, false). + attributed_meaning_to_string(*ameaning, String::L_HTTP_HEADER, false). cstr(String::L_UNSPECIFIED)); } void Request::output_result(VFile* body_file, bool header_only, bool as_attachment) { @@ -660,32 +667,19 @@ const String& Request::mime_type_of(cons } #ifdef XML - GdomeDOMString_auto_ptr Request::transcode(const String& s) { return charsets.source().transcode(s); } -const String& Request::transcode(GdomeDOMString* s -#ifndef NO_STRING_ORIGIN - , const String& origin -#endif - ) { - return charsets.source().transcode(s -#ifndef NO_STRING_ORIGIN - , origin -#endif - ); +GdomeDOMString_auto_ptr Request::transcode(const StringBody s) { + return charsets.source().transcode(s); } -const String& Request::transcode(xmlChar* s -#ifndef NO_STRING_ORIGIN - , const String& origin -#endif - ) { - return charsets.source().transcode(s -#ifndef NO_STRING_ORIGIN - , origin -#endif - ); +const String& Request::transcode(GdomeDOMString* s) { + return charsets.source().transcode(s); +} + +const String& Request::transcode(xmlChar* s) { + return charsets.source().transcode(s); } #endif