--- parser3/src/main/pa_request.C 2003/04/03 11:19:50 1.245.2.37.2.25 +++ parser3/src/main/pa_request.C 2003/07/24 11:31:24 1.248 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_REQUEST_C="$Date: 2003/04/03 11:19:50 $"; +static const char* IDENT_REQUEST_C="$Date: 2003/07/24 11:31:24 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -189,8 +189,11 @@ Request::~Request() { Value& Request::get_self() { return method_frame/*always have!*/->self(); } -static void load_charset(HashStringValue::key_type akey, HashStringValue::value_type avalue, int) { - ::charsets.load_charset(*new String(akey, String::L_CLEAN), avalue->as_string()); +static void load_charset(HashStringValue::key_type akey, + HashStringValue::value_type avalue, + Request_charsets* charsets) { + const StringBody NAME=String(akey, String::L_CLEAN).change_case(charsets->source(), String::CC_UPPER); + ::charsets.load_charset(*charsets, NAME, avalue->as_string()); } void Request::configure_admin(VStateless_class& conf_class) { if(configure_admin_done) @@ -210,7 +213,7 @@ 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, 0); + charsets->for_each(load_charset, &this->charsets); else throw Exception("parser.runtime", 0, @@ -395,13 +398,13 @@ t[9]-t[3] if(details.problem_source) { // do we know the guy? if(details.trace) { // do whe know where he came from? - Operation::Info origin=details.trace.origin(); + Operation::Origin origin=details.trace.origin(); SAPI::log(sapi_info, PA_URI_FORMAT PA_ORIGIN_FILE_POS_FORMAT PA_SOURCE_FORMAT PA_COMMENT_TYPE_FORMAT, request_info.uri, - file_list[origin.file_no], 1+origin.line, 1+origin.col, + file_list[origin.file_no].cstr(), 1+origin.line, 1+origin.col, details.problem_source->cstr(), e.comment(), e.type() ); @@ -453,12 +456,12 @@ Table::columns_type stack_trace_columns( *stack_trace_columns+=new String("colno"); Table& stack_trace=*new Table(stack_trace_columns); if(!exception_trace.is_empty()/*signed!*/) - for(size_t i=exception_trace.bottom_index(); i<=exception_trace.top_index(); i++) { + for(size_t i=exception_trace.bottom_index(); iget_hash()) body_file_content_type=hash->get(value_name); - if(!body_file_content_type/*vstring.as_vfile*/ || body_file_content_type->as_string().pos("text/")==0) { - Charset::transcode( - charsets.source(), body_file->value_ptr(), body_file->value_size(), - charsets.client(), client_body, client_content_length - ); - } else { - client_body=body_file->value_ptr(); - client_content_length=body_file->value_size(); - } + String::C output(body_file->value_ptr(), body_file->value_size()); + if(!body_file_content_type/*vstring.as_vfile*/ || body_file_content_type->as_string().pos("text/")==0) + output=Charset::transcode(output, + charsets.source(), + charsets.client()); // prepare header: content-length char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%u", client_content_length); + snprintf(content_length_cstr, MAX_NUMBER, "%u", output.length); SAPI::add_header_attribute(sapi_info, "content-length", content_length_cstr); // send header @@ -686,14 +690,15 @@ void Request::output_result(VFile* body_ // send body if(!header_only) - SAPI::send_body(sapi_info, client_body, client_content_length); + SAPI::send_body(sapi_info, output.str, output.length); } const String& Request::mime_type_of(const char* user_file_name_cstr) { if(mime_types) if(const char* cext=strrchr(user_file_name_cstr, '.')) { String sext(++cext); - if(mime_types->locate(0, sext.change_case(charsets.source(), String::CC_LOWER))) + Table::Action_options options; + if(mime_types->locate(0, sext.change_case(charsets.source(), String::CC_LOWER), options)) if(const String* result=mime_types->item(1)) return *result; else @@ -733,8 +738,9 @@ const Request::Trace Request::Exception_ fbottom++; } else if(result.name()==problem_source) // it is that same guy? fbottom++; // throw away that trace - else // stack top contains not us - result.clear(); + // else stack top contains not us, + // leaving result intact + // it would help ^throw } return result; @@ -760,7 +766,7 @@ Request::Exception_details Request::get_ // $.file lineno colno if(trace) { - const Operation::Info origin=trace.origin(); + const Operation::Origin origin=trace.origin(); hash.put(StringBody("file"), new VString(*new String(file_list[origin.file_no], String::L_TAINTED))); hash.put(StringBody("lineno"), new VInt(1+origin.line)); @@ -777,5 +783,3 @@ Request::Exception_details Request::get_ return Request::Exception_details(trace, problem_source, vhash); } - -// \ No newline at end of file