--- parser3/src/main/pa_request.C 2002/10/31 12:22:13 1.236.4.1 +++ parser3/src/main/pa_request.C 2003/04/21 06:03:30 1.247 @@ -1,11 +1,11 @@ /** @file Parser: request class main part. @see compile.C and execute.C. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_REQUEST_C="$Date: 2002/10/31 12:22:13 $"; +static const char* IDENT_REQUEST_C="$Date: 2003/04/21 06:03:30 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -68,7 +68,8 @@ Request::Request(Pool& apool, #ifdef RESOURCES_DEBUG , sql_connect_time(0),sql_request_time(0) #endif - , method_frame(0), rcontext(0), wcontext(0) + , method_frame(0), rcontext(0), wcontext(0), + finterrupted(false) { // default charsets pool().set_source_charset(*utf8_charset); @@ -139,12 +140,13 @@ void Request::configure_admin(VStateless ] */ if(Value *vcharsets=conf_class.get_element(*charsets_name, conf_class, false)) { - if(Hash *charsets=vcharsets->get_hash(0)) - charsets->for_each(load_charset); - else if(!vcharsets->get_string()) - throw Exception("parser.runtime", - 0, - "$" MAIN_CLASS_NAME ":" CHARSETS_NAME " must be hash"); + if(!vcharsets->is_string()) + if(Hash *charsets=vcharsets->get_hash(0)) + charsets->for_each(load_charset); + else + throw Exception("parser.runtime", + 0, + "$" MAIN_CLASS_NAME ":" CHARSETS_NAME " must be hash"); } // configure method_frame options @@ -284,7 +286,12 @@ gettimeofday(&mt[2],NULL); // extract response body Value *body_value=static_cast( - response.fields().get(*body_name)); + response.fields().get(*download_name)); + bool as_attachment=body_value!=0; + if(!body_value) + body_value=static_cast( + response.fields().get(*body_name)); + if(body_value) // there is some $response:body body_file=body_value->as_vfile(); else if(lorigins_mode) @@ -297,7 +304,7 @@ gettimeofday(&mt[3],NULL); #endif // OK. write out the result - output_result(*body_file, header_only); + output_result(*body_file, header_only, as_attachment); #ifdef RESOURCES_DEBUG //measure:after output_result @@ -435,7 +442,7 @@ t[9]-t[3] const VFile *body_file=body_vstring.as_vfile(); // ERROR. write it out - output_result(*body_file, header_only); + output_result(*body_file, header_only, false); } catch(const Exception& ) { /*re*/throw; } @@ -538,13 +545,23 @@ const String& Request::absolute(const St result << relative_name; return result; } else - return relative(info.path_translated, relative_name); + if(relative_name.pos("://")>0 // something like "http://xxx" +#ifdef WIN32 + || relative_name.pos(":")==1 // DRIVE: + || relative_name.starts_with("\\\\") // UNC1 + || relative_name.starts_with("//") // UNC2 +#endif + ) + return relative_name; + else + return relative(info.path_translated, relative_name); } static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, void *info) { Request& r=*static_cast(info); if(aattribute==BODY_NAME + || aattribute==DOWNLOAD_NAME || aattribute==CHARSET_NAME) return; @@ -553,9 +570,10 @@ static void add_header_attribute(const H SAPI::add_header_attribute(pool, aattribute.cstr(), - attributed_meaning_to_string(lmeaning, String::UL_HTTP_HEADER).cstr()); + attributed_meaning_to_string(lmeaning, String::UL_HTTP_HEADER, false) + .cstr(String::UL_UNSPECIFIED)); } -void Request::output_result(const VFile& body_file, bool header_only) { +void Request::output_result(const VFile& body_file, bool header_only, bool as_attachment) { // header: cookies cookie.output_result(); @@ -576,7 +594,10 @@ 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(0).put(*content_disposition_filename_name, vfile_name); + Hash& hash=vhash.hash(0); + if(as_attachment) + hash.put(*value_name, NEW VString(*content_disposition_value)); + hash.put(*content_disposition_filename_name, vfile_name); response.fields().put(*content_disposition_name, &vhash); } @@ -616,7 +637,8 @@ const String& Request::mime_type_of(cons if(mime_types) if(const char *cext=strrchr(user_file_name_cstr, '.')) { String sext(pool(), ++cext); - if(mime_types->locate(0, sext.change_case(pool(), String::CC_LOWER))) + Table::Action_options options; + if(mime_types->locate(0, sext.change_case(pool(), String::CC_LOWER), options)) if(const String *result=mime_types->item(1)) return *result; else