--- parser3/src/main/pa_request.C 2001/04/07 13:48:42 1.102 +++ parser3/src/main/pa_request.C 2001/04/08 13:11:19 1.104 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.102 2001/04/07 13:48:42 paf Exp $ + $Id: pa_request.C,v 1.104 2001/04/08 13:11:19 paf Exp $ */ #include "pa_config_includes.h" @@ -55,7 +55,8 @@ Request::Request(Pool& apool, used_files(apool), default_content_type(0), mime_types(0), - connection(0), protocol2library(0) + connection(0), protocol2library(0), + mail(0) { // root superclass, // parent of all classes, @@ -473,8 +474,7 @@ const String& Request::relative(const ch memcpy(lpath, apath, lpath_buf_size); rsplit(lpath, '/'); String& result=*NEW String(pool(), lpath); - result.APPEND_CONST("/"); - result.append(relative_name, String::UL_PASS_APPENDED); + result << "/" << relative_name; return result; } @@ -482,7 +482,7 @@ const String& Request::absolute(const St char *relative_name_cstr=relative_name.cstr(); if(relative_name_cstr[0]=='/') { String& result=*NEW String(pool(), info.document_root); - result.append(relative_name, String::UL_PASS_APPENDED); + result << relative_name; return result; } else return relative(info.path_translated, relative_name); @@ -546,3 +546,18 @@ void Request::output_result(const VFile& if(!header_only) SAPI::send_body(pool(), body, content_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(pool(), ++cext); + if(mime_types->locate(0, sext)) + if(const String *result=mime_types->item(1)) + return *result; + else + THROW(0, 0, + mime_types->origin_string(), + "MIME-TYPE table column elements must not be empty"); + } + return *NEW String(pool(), "application/octet-stream"); +} \ No newline at end of file