--- parser3/src/main/pa_request.C 2005/12/16 10:15:12 1.280 +++ 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: 2005/12/16 10:15:12 $"; +static const char * const IDENT_REQUEST_C="$Date: 2007/04/23 10:30:32 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -59,6 +59,7 @@ const char* ORIGINS_CONTENT_TYPE="text/p const String main_method_name(MAIN_METHOD_NAME); const String auto_method_name(AUTO_METHOD_NAME); const String content_disposition_name(CONTENT_DISPOSITION_NAME); +const String content_disposition_inline(CONTENT_DISPOSITION_INLINE); const String content_disposition_value(CONTENT_DISPOSITION_VALUE); const String content_disposition_filename_name(CONTENT_DISPOSITION_FILENAME_NAME); const String body_name(BODY_NAME); @@ -107,7 +108,7 @@ Request::Request(SAPI_Info& asapi_info, wcontext(0), flang(adefault_lang), fconnection(0), - finterrupted(false), + finterrupted(false),fskip(SKIP_NOTHING), // public #ifdef RESOURCES_DEBUG @@ -125,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), @@ -161,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); @@ -204,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; @@ -220,9 +221,9 @@ void Request::configure_admin(VStateless if(Value* vcharsets=conf_class.get_element(charsets_name, conf_class, false)) { if(!vcharsets->is_string()) if(HashStringValue* charsets=vcharsets->get_hash()) - charsets->for_each(load_charset, &this->charsets); + 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"); } @@ -373,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"); @@ -569,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"); } @@ -836,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())); @@ -862,7 +861,7 @@ void Request::output_result(VFile* body_ // prepare header: $response:fields without :body Add_header_attribute_info info(*this); - response.fields().for_each(add_header_attribute, &info); + response.fields().for_each(add_header_attribute, &info); if(body_file_content_type) if(HashStringValue *hash=body_file_content_type->get_hash()) @@ -881,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); @@ -906,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"); }