--- parser3/src/main/pa_request.C 2006/11/16 18:03:13 1.282 +++ parser3/src/main/pa_request.C 2007/04/23 10:30:32 1.286 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2006/11/16 18:03:13 $"; +static const char * const IDENT_REQUEST_C="$Date: 2007/04/23 10:30:32 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -126,6 +126,7 @@ Request::Request(SAPI_Info& asapi_info, mail(*new VMail), response(*new VResponse(arequest_info, charsets)), cookie(*new VCookie), + console(*new VConsole), // private configure_admin_done(false), @@ -162,8 +163,7 @@ Request::Request(SAPI_Info& asapi_info, // cookie class classes().put(String::Body(COOKIE_CLASS_NAME), &cookie); // console class - classes().put(String::Body(CONSOLE_CLASS_NAME), new VConsole()); - + classes().put(String::Body(CONSOLE_CLASS_NAME), &console); /// methoded // response class classes().put(response.get_class()->name(), &response); @@ -205,7 +205,7 @@ static void load_charset(HashStringValue } void Request::configure_admin(VStateless_class& conf_class) { if(configure_admin_done) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "parser already configured"); configure_admin_done=true; @@ -223,7 +223,7 @@ void Request::configure_admin(VStateless if(HashStringValue* charsets=vcharsets->get_hash()) charsets->for_each(load_charset, &this->charsets); else - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":" CHARSETS_NAME " must be hash"); } @@ -374,7 +374,7 @@ gettimeofday(&mt[1],NULL); // execute @main[] const String* body_string=execute_virtual_method(main_class, main_method_name); if(!body_string) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "'"MAIN_METHOD_NAME"' method not found"); @@ -570,16 +570,16 @@ void Request::use_file(VStateless_class& break; // found along class_path } } else - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "$" CLASS_PATH_NAME " must be string or table"); if(!file_spec) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, &file_name, "not found along " MAIN_CLASS_NAME ":" CLASS_PATH_NAME); } if(!file_spec) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, &file_name, "usage failed - no $" MAIN_CLASS_NAME ":" CLASS_PATH_NAME " were specified"); } @@ -837,14 +837,12 @@ void Request::output_result(VFile* body_ if(vfile_name) { const String& sfile_name=vfile_name->as_string(); if(sfile_name!=NONAME_DAT) { - if(as_attachment) - { - VHash& hash=*new VHash(); - HashStringValue &h=hash.hash(); - h.put(value_name, new VString(content_disposition_value)); - h.put(content_disposition_filename_name, vfile_name); - response.fields().put(content_disposition_name, &hash); - } + VHash& hash=*new VHash(); + HashStringValue &h=hash.hash(); + h.put(value_name, new VString( as_attachment ? content_disposition_value : content_disposition_inline )); + + h.put(content_disposition_filename_name, vfile_name); + response.fields().put(content_disposition_name, &hash); if(!body_file_content_type) body_file_content_type=new VString(mime_type_of(sfile_name.cstr())); @@ -882,7 +880,7 @@ void Request::output_result(VFile* body_ if(Value* vdatep=v->as(VDATE_TYPE, false)) vdate=static_cast(vdatep); else - throw Exception("parser.runtime", 0, "mdate must be a date"); + throw Exception(PARSER_RUNTIME, 0, "mdate must be a date"); } if(!vdate) vdate=new VDate(mtime); @@ -907,7 +905,7 @@ const String& Request::mime_type_of(cons if(const String* result=mime_types->item(1)) return *result; else - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, MIME_TYPES_NAME " table column elements must not be empty"); }