--- parser3/src/main/pa_request.C 2001/03/18 17:18:36 1.47 +++ parser3/src/main/pa_request.C 2001/03/18 17:39:29 1.49 @@ -3,7 +3,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.47 2001/03/18 17:18:36 paf Exp $ + $Id: pa_request.C,v 1.49 2001/03/18 17:39:29 paf Exp $ */ #include @@ -69,31 +69,29 @@ static void append_attribute_subattribut Value *value=static_cast(avalue); string->append(value->as_string(), String::Untaint_lang::URI, true); } -static void output_response_attribute(const Hash::Key& akey, Hash::Value *ameaning, +static void output_response_attribute(const Hash::Key& aattribute, Hash::Value *ameaning, void *info) { - String *key_to_exclude=static_cast(info); - if(akey==*key_to_exclude) + String *attribute_to_exclude=static_cast(info); + if(aattribute==*attribute_to_exclude) return; - String key(akey.pool()); - key.append(akey, String::Untaint_lang::URI, true); + String attribute(aattribute.pool()); + attribute.append(aattribute, String::Untaint_lang::URI, true); Value *meaning=static_cast(ameaning); String string(meaning->pool()); - if(VHash *vhash=meaning->get_hash()) { + if(Hash *hash=meaning->get_hash()) { // $value(value) $subattribute(subattribute value) - Hash& hash=vhash->hash(); - - Value *value=static_cast(hash.get(*value_name)); + Value *value=static_cast(hash->get(*value_name)); if(value) string.append(value->as_string(), String::Untaint_lang::URI, true); - hash.foreach(append_attribute_subattribute, &string); + hash->foreach(append_attribute_subattribute, &string); } else // string value string.append(meaning->as_string(), String::Untaint_lang::URI, true); (*service_funcs.output_header_attribute)( - key.cstr(), + attribute.cstr(), string.cstr()); } @@ -149,9 +147,7 @@ void Request::core(Exception& system_exc // $MAIN:defaults Value *defaults=main_class?main_class->get_element(*defaults_name):0; - // $defaults.content-type - if(fdefault_content_type=defaults?defaults->get_element(*content_type_name):0) - response.fields().put(*content_type_name, fdefault_content_type); + fdefault_content_type=defaults?defaults->get_element(*content_type_name):0; // there must be some auto.p if(!main_class) @@ -189,9 +185,6 @@ void Request::core(Exception& system_exc // reset response response.fields().clear(); - // this is what we'd return in $response:content-type - Value *content_type; - // this is what we'd return in $response:body const String *body_string=0; @@ -267,9 +260,6 @@ void Request::core(Exception& system_exc code_value=NEW VUnknown(pool()); frame.store_param(code_name, code_value); - // future $response:content-type= - // content-type from any auto.p - content_type=fdefault_content_type; // future $response:body= // execute ^exception[origin;source;comment;type;code] body_string=execute_method(frame, *method); @@ -306,16 +296,12 @@ void Request::core(Exception& system_exc } // future $response:content-type - String &content_type_value=*NEW String(pool(), "text/plain"); - content_type=NEW VString(content_type_value); + response.fields().put(*content_type_name, + NEW VString(*NEW String(pool(), "text/plain"))); // future $response:body body_string=NEW String(pool(), buf); } - // set $response:content-type - if(content_type) - response.fields().put(*content_type_name, content_type); - // ERROR. write it out output_result(*body_string); } @@ -391,6 +377,9 @@ char *Request::absolute(const char *name } void Request::output_result(const String& body_string) { + // set default content-type + response.fields().put_dont_replace(*content_type_name, fdefault_content_type); + // header: response fields response.fields().foreach(output_response_attribute, /*excluding*/ body_name); const char *body=body_string.cstr();