--- parser3/src/targets/cgi/parser3.C 2020/12/16 11:15:49 1.334 +++ parser3/src/targets/cgi/parser3.C 2020/12/17 13:44:16 1.339 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.334 2020/12/16 11:15:49 moko Exp $"; +volatile const char * IDENT_PARSER3_C="$Id: parser3.C,v 1.339 2020/12/17 13:44:16 moko Exp $"; #include "pa_config_includes.h" @@ -59,7 +59,7 @@ static const char* filespec_4log = NULL; // SAPI -void log(const char* fmt, va_list args) { +static void pa_log(const char* fmt, va_list args) { bool opened=false; FILE *f=0; @@ -119,20 +119,18 @@ void log(const char* fmt, va_list args) fflush(f); } -#ifdef PA_DEBUG_CGI_ENTRY_EXIT -static void log(const char* fmt, ...) { +void pa_log(const char* fmt, ...) { va_list args; va_start(args,fmt); - log(fmt, args); + pa_log(fmt, args); va_end(args); } -#endif // appends to parser3.log located next to the config file if openable, to stderr otherwize void SAPI::log(SAPI_Info&, const char* fmt, ...) { va_list args; va_start(args,fmt); - ::log(fmt, args); + pa_log(fmt, args); va_end(args); } @@ -141,7 +139,7 @@ void SAPI::die(const char* fmt, ...) { // logging first, first vsnprintf va_start(args,fmt); - ::log(fmt, args); + pa_log(fmt, args); va_end(args); // inform user, second vsnprintf @@ -317,7 +315,7 @@ static void connection_handler(SAPI_Info try { memset(&request_info, 0, sizeof(request_info)); - if(connection.read_header()) + if(!connection.read_header()) return; // ignore "void" connections info.populate_env(); @@ -341,7 +339,11 @@ static void connection_handler(SAPI_Info r.core(config_filespec, strcasecmp(request_info.method, "HEAD")==0, String("httpd-main")); } catch(const Exception& e) { // exception in connection handling or unhandled exception SAPI::log(info, "%s", e.comment()); - SAPI::send_error(info, e.comment(), info.exception_http_status(e.type())); + const char *status = info.exception_http_status(e.type()); + if(*status){ + info.clear_response_headers(); + SAPI::send_error(info, e.comment(), status); + } } } @@ -393,6 +395,7 @@ static void httpd_mode() { connection.sock = -1; break; #else +#ifdef HAVE_TLS pthread_t thread; pthread_attr_t attr; pthread_attr_init(&attr); @@ -402,6 +405,7 @@ static void httpd_mode() { throw Exception("httpd.fork", 0, "thread creation failed (%d)", result); connection.sock=-1; break; +#endif case HTTPD_Server::PARALLEL: pid=fork(); if(pid<0)