--- parser3/src/targets/apache/mod_parser3_core.C 2020/10/10 06:08:37 1.23 +++ parser3/src/targets/apache/mod_parser3_core.C 2020/10/14 00:07:42 1.26 @@ -5,7 +5,7 @@ Parser: apache 1.3/2.X module, part, com Author: Alexandr Petrosian (http://paf.design.ru) */ -volatile const char * IDENT_MOD_PARSER3_CORE_C="$Id: mod_parser3_core.C,v 1.23 2020/10/10 06:08:37 moko Exp $"; +volatile const char * IDENT_MOD_PARSER3_CORE_C="$Id: mod_parser3_core.C,v 1.26 2020/10/14 00:07:42 moko Exp $"; #include "pa_config_includes.h" @@ -96,9 +96,8 @@ static const char* mk_env_pair(const cha } static int SAPI_environment_append(void *d, const char* k, const char* val) { - if( k && val ) { - SAPI_environment_append_info& info= - *static_cast(d); + if(k && val) { + SAPI_environment_append_info& info=*static_cast(d); *info.cur++=mk_env_pair(k, val); } return 1/*true*/; @@ -149,7 +148,7 @@ void SAPI::add_header_attribute(SAPI_Inf */ *SAPI_info.r->content_type = pa_ap_pstrdup(SAPI_info.r->pool, dont_store_value); } else if(strcasecmp(dont_store_key, HTTP_STATUS)==0) - *SAPI_info.r->status=pa_atoi(dont_store_value, 10); + *SAPI_info.r->status=atoi(dont_store_value); else pa_ap_table_addn(SAPI_info.r->headers_out, pa_ap_pstrdup(SAPI_info.r->pool, capitalize(dont_store_key)), @@ -250,7 +249,7 @@ int pa_parser_handler(pa_request_rec *r, // SAPI info SAPI_Info SAPI_info; SAPI_info.r=r; - if(r->file_not_found ) + if(r->file_not_found) return PA_HTTP_NOT_FOUND; try { // global try @@ -262,34 +261,10 @@ int pa_parser_handler(pa_request_rec *r, SAPI_info, dcfg); // successful finish - } catch(const Exception& e) { // global problem - // don't allocate anything on pool here: - // possible pool' exception not catch-ed now - // and there could be out-of-memory exception - char buf[MAX_STRING]; - snprintf(buf, MAX_STRING, "Unhandled exception %s", e.comment()); + } catch(const Exception& e) { // exception in unhandled exception // log it - SAPI::log(SAPI_info, "%s", buf); - - // - int content_length=strlen(buf); - - // prepare header - // capitalized headers are used for preventing malloc during capitalization - SAPI::add_header_attribute(SAPI_info, HTTP_CONTENT_TYPE_CAPITALIZED, "text/plain"); - // don't use 'format' function because it calls malloc - char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%u", content_length); - SAPI::add_header_attribute(SAPI_info, HTTP_CONTENT_LENGTH_CAPITALIZED, content_length_cstr); - - // send header - SAPI::send_header(SAPI_info); - - // send body - if(!r->header_only) - SAPI::send_body(SAPI_info, buf, content_length); - - // unsuccessful finish + SAPI::log(SAPI_info, "%s", e.comment()); + SAPI::send_error(SAPI_info, e.comment()); } /*