|
|
| version 1.236.4.1, 2002/10/31 12:22:13 | version 1.244, 2002/12/19 10:17:42 |
|---|---|
| Line 68 Request::Request(Pool& apool, | Line 68 Request::Request(Pool& apool, |
| #ifdef RESOURCES_DEBUG | #ifdef RESOURCES_DEBUG |
| , sql_connect_time(0),sql_request_time(0) | , sql_connect_time(0),sql_request_time(0) |
| #endif | #endif |
| , method_frame(0), rcontext(0), wcontext(0) | , method_frame(0), rcontext(0), wcontext(0), |
| finterrupted(false) | |
| { | { |
| // default charsets | // default charsets |
| pool().set_source_charset(*utf8_charset); | pool().set_source_charset(*utf8_charset); |
| Line 139 void Request::configure_admin(VStateless | Line 140 void Request::configure_admin(VStateless |
| ] | ] |
| */ | */ |
| if(Value *vcharsets=conf_class.get_element(*charsets_name, conf_class, false)) { | if(Value *vcharsets=conf_class.get_element(*charsets_name, conf_class, false)) { |
| if(Hash *charsets=vcharsets->get_hash(0)) | if(!vcharsets->is_string()) |
| charsets->for_each(load_charset); | if(Hash *charsets=vcharsets->get_hash(0)) |
| else if(!vcharsets->get_string()) | charsets->for_each(load_charset); |
| throw Exception("parser.runtime", | else |
| 0, | throw Exception("parser.runtime", |
| "$" MAIN_CLASS_NAME ":" CHARSETS_NAME " must be hash"); | 0, |
| "$" MAIN_CLASS_NAME ":" CHARSETS_NAME " must be hash"); | |
| } | } |
| // configure method_frame options | // configure method_frame options |
| Line 284 gettimeofday(&mt[2],NULL); | Line 286 gettimeofday(&mt[2],NULL); |
| // extract response body | // extract response body |
| Value *body_value=static_cast<Value *>( | Value *body_value=static_cast<Value *>( |
| response.fields().get(*body_name)); | response.fields().get(*download_name)); |
| bool as_attachment=body_value!=0; | |
| if(!body_value) | |
| body_value=static_cast<Value *>( | |
| response.fields().get(*body_name)); | |
| if(body_value) // there is some $response:body | if(body_value) // there is some $response:body |
| body_file=body_value->as_vfile(); | body_file=body_value->as_vfile(); |
| else if(lorigins_mode) | else if(lorigins_mode) |
| Line 297 gettimeofday(&mt[3],NULL); | Line 304 gettimeofday(&mt[3],NULL); |
| #endif | #endif |
| // OK. write out the result | // OK. write out the result |
| output_result(*body_file, header_only); | output_result(*body_file, header_only, as_attachment); |
| #ifdef RESOURCES_DEBUG | #ifdef RESOURCES_DEBUG |
| //measure:after output_result | //measure:after output_result |
| Line 435 t[9]-t[3] | Line 442 t[9]-t[3] |
| const VFile *body_file=body_vstring.as_vfile(); | const VFile *body_file=body_vstring.as_vfile(); |
| // ERROR. write it out | // ERROR. write it out |
| output_result(*body_file, header_only); | output_result(*body_file, header_only, false); |
| } catch(const Exception& ) { | } catch(const Exception& ) { |
| /*re*/throw; | /*re*/throw; |
| } | } |
| Line 538 const String& Request::absolute(const St | Line 545 const String& Request::absolute(const St |
| result << relative_name; | result << relative_name; |
| return result; | return result; |
| } else | } else |
| return relative(info.path_translated, relative_name); | return relative_name.pos("://")<0? relative(info.path_translated, relative_name) |
| :relative_name; // something like "http://xxx" | |
| } | } |
| static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, | static void add_header_attribute(const Hash::Key& aattribute, Hash::Val *ameaning, |
| void *info) { | void *info) { |
| Request& r=*static_cast<Request *>(info); | Request& r=*static_cast<Request *>(info); |
| if(aattribute==BODY_NAME | if(aattribute==BODY_NAME |
| || aattribute==DOWNLOAD_NAME | |
| || aattribute==CHARSET_NAME) | || aattribute==CHARSET_NAME) |
| return; | return; |
| Line 553 static void add_header_attribute(const H | Line 562 static void add_header_attribute(const H |
| SAPI::add_header_attribute(pool, | SAPI::add_header_attribute(pool, |
| aattribute.cstr(), | 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 | // header: cookies |
| cookie.output_result(); | cookie.output_result(); |
| Line 576 void Request::output_result(const VFile& | Line 586 void Request::output_result(const VFile& |
| if(VString *vfile_name=static_cast<VString *>(body_file.fields().get(*name_name))) | if(VString *vfile_name=static_cast<VString *>(body_file.fields().get(*name_name))) |
| if(vfile_name->string()!=NONAME_DAT) { | if(vfile_name->string()!=NONAME_DAT) { |
| VHash& vhash=*NEW VHash(pool()); | 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); | response.fields().put(*content_disposition_name, &vhash); |
| } | } |