Annotation of parser3/src/targets/cgi/parser3.C, revision 1.180

1.27      paf         1: /** @file
                      2:        Parser: scripting and CGI main.
                      3: 
1.155     paf         4:        Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.154     paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.27      paf         6: 
1.180   ! paf         7:        $Id: parser3.C,v 1.179 2002/06/03 15:02:41 paf Exp $
1.1       paf         8: */
                      9: 
1.40      paf        10: #include "pa_config_includes.h"
1.3       paf        11: 
1.139     paf        12: #if _MSC_VER
1.131     paf        13: #      include <new.h>
1.148     paf        14: #      include <crtdbg.h>
1.151     paf        15: #else
                     16: #      include "pa_config_paths.h"
1.3       paf        17: #endif
1.27      paf        18: 
1.37      paf        19: #include "pa_sapi.h"
1.76      paf        20: #include "classes.h"
1.24      paf        21: #include "pa_common.h"
1.2       paf        22: #include "pa_request.h"
1.57      paf        23: #include "pa_socks.h"
1.68      paf        24: #include "pa_version.h"
1.125     parser     25: #include "pool_storage.h"
1.69      paf        26: 
1.149     paf        27: #ifdef WIN32
                     28: #      include <windows.h>
1.120     parser     29: #endif
                     30: 
1.158     paf        31: //#define DEBUG_POOL_MALLOC
1.162     paf        32: //#define DEBUG_STRING_APPENDS_VS_EXPANDS
1.160     paf        33: 
                     34: #ifdef DEBUG_STRING_APPENDS_VS_EXPANDS
                     35: extern ulong 
                     36:        string_piece_appends, 
                     37:        wcontext_result_size,
                     38:        total_alloc_size,
                     39:        string_string_shortcut_economy;
                     40: #endif
1.84      parser     41: 
1.109     parser     42: // consts
1.113     parser     43: 
1.174     paf        44: #ifndef _PROFILE
1.113     parser     45: extern const char *main_RCSIds[];
1.116     parser     46: #ifdef USE_SMTP
1.113     parser     47: extern const char *smtp_RCSIds[];
1.114     parser     48: #endif
1.113     parser     49: extern const char *gd_RCSIds[];
                     50: extern const char *classes_RCSIds[];
                     51: extern const char *types_RCSIds[];
1.115     parser     52: extern const char *parser3_RCSIds[];
1.113     parser     53: const char **RCSIds[]={
                     54:        main_RCSIds,
1.116     parser     55: #ifdef USE_SMTP
1.113     parser     56:        smtp_RCSIds,
1.114     parser     57: #endif
1.113     parser     58:        gd_RCSIds,
                     59:        classes_RCSIds,
                     60:        types_RCSIds,
1.115     parser     61:        parser3_RCSIds,
1.113     parser     62:        0
                     63: };
1.174     paf        64: #endif
1.84      parser     65: 
1.175     paf        66: #define REDIRECT_PREFIX "REDIRECT_"
                     67: #define PARSER_ROOT_CONFIG_ENV_NAME "HTTP_PARSER_ROOT_CONFIG"
                     68: #define PARSER_SITE_CONFIG_ENV_NAME "HTTP_PARSER_SITE_CONFIG"
1.159     paf        69: 
1.42      paf        70: /// IIS refuses to read bigger chunks
                     71: const size_t READ_POST_CHUNK_SIZE=0x400*0x400; // 1M 
                     72: 
1.45      paf        73: const char *argv0;
1.178     paf        74: Pool *pool; // global pool [dont describe to doxygen: it confuses it with param names]
1.27      paf        75: bool cgi; ///< we were started as CGI?
1.5       paf        76: 
1.46      paf        77: // SAPI
1.86      parser     78: 
1.124     parser     79: static void log(const char *fmt, va_list args) {
1.61      paf        80:        bool opened;
                     81:        FILE *f=0;
                     82: 
                     83:        if(argv0) {
                     84:                // beside by binary
                     85:                char file_spec[MAX_STRING];
1.98      parser     86:                strncpy(file_spec, argv0, MAX_STRING-1);  file_spec[MAX_STRING-1]=0; // filespec of my binary
1.61      paf        87:                rsplit(file_spec, '/');  rsplit(file_spec, '\\');// strip filename
                     88:                strcat(file_spec, "/parser3.log");
                     89:                f=fopen(file_spec, "at");
                     90:        }
                     91:        opened=f!=0;
                     92:        if(!opened)
                     93:                f=stderr;
                     94: 
                     95:        // prefix
                     96:        time_t t=time(0);
1.171     paf        97:        if(const char *stamp=ctime(&t)) { // never saw that
1.173     paf        98:                if(size_t len=strlen(stamp)) // saw once stamp being =""
1.172     paf        99:                        fprintf(f, "[%.*s] ", len-1, stamp);
1.171     paf       100:        }
1.61      paf       101:        // message
1.117     parser    102: 
                    103:        char buf[MAX_STRING];
                    104:        size_t size=vsnprintf(buf, MAX_STRING, fmt, args);
                    105:        remove_crlf(buf, buf+size);
                    106: 
                    107:        fwrite(buf, size, 1, f);
1.61      paf       108:        // newline
                    109:        fprintf(f, "\n");
                    110: 
                    111:        if(opened)
                    112:                fclose(f);
1.85      parser    113:        else
                    114:                fflush(f);
1.124     parser    115: }
                    116: 
                    117: // appends to parser3.log located beside my binary if openable, to stderr otherwize
                    118: void SAPI::log(Pool& , const char *fmt, ...) {
                    119:     va_list args;
                    120:        va_start(args,fmt);
                    121:        ::log(fmt, args);
                    122:        va_end(args);
                    123: }
                    124: 
                    125: void SAPI::die(const char *fmt, ...) {
1.137     paf       126: #ifdef DEBUG_POOL_MALLOC
                    127:        extern void log_pool_stats(Pool& pool);
1.178     paf       128:        log_pool_stats(*pool);
1.137     paf       129: #endif
                    130: 
1.144     paf       131:     va_list args;
                    132:        va_start(args,fmt);
1.138     paf       133:        // log
                    134: 
                    135:        // logging is more important than user 
                    136:        // she can cancel download, we'd get SIG_PIPE, 
                    137:        // nothing would be logged then
1.124     parser    138:        ::log(fmt, args);
                    139: 
1.138     paf       140:        // inform user
                    141: 
1.134     paf       142:        char body[MAX_STRING];
1.138     paf       143:        int content_length=vsnprintf(body, MAX_STRING, fmt, args);
1.134     paf       144: 
1.144     paf       145:        va_end(args);
                    146: 
1.134     paf       147:        // prepare header
                    148:        // let's be honest, that's bad we couldn't produce valid output
1.178     paf       149:        SAPI::add_header_attribute(*pool, "status", "500");
                    150:        SAPI::add_header_attribute(*pool, "content-type", "text/plain");
1.134     paf       151:        char content_length_cstr[MAX_NUMBER];
1.168     paf       152:        snprintf(content_length_cstr, sizeof(content_length_cstr), "%u", content_length);
1.178     paf       153:        SAPI::add_header_attribute(*pool, "content-length", content_length_cstr);
1.134     paf       154: 
                    155:        // send header
1.178     paf       156:        SAPI::send_header(*pool);
1.134     paf       157: 
                    158:        // body
1.178     paf       159:        SAPI::send_body(*pool, body, content_length);
1.134     paf       160: 
1.124     parser    161:        exit(1);
1.61      paf       162: }
                    163: 
1.122     parser    164: const char *SAPI::get_env(Pool& , const char *name) {
1.109     parser    165:        return getenv(name);
1.28      paf       166: }
                    167: 
1.180   ! paf       168: const char *const *SAPI::environment(Pool&) {
        !           169: #ifdef _MSC_VER
        !           170:        extern char **_environ;
        !           171:        return _environ;
        !           172: #else
        !           173:        extern char **environ;
        !           174:        return environ;
        !           175: #endif
        !           176: }
        !           177: 
1.122     parser    178: size_t SAPI::read_post(Pool& , char *buf, size_t max_bytes) {
1.59      paf       179:        size_t read_size=0;
1.12      paf       180:        do {
1.36      paf       181:                int chunk_size=read(fileno(stdin), 
1.42      paf       182:                        buf+read_size, min(READ_POST_CHUNK_SIZE, max_bytes-read_size));
1.129     paf       183:                if(chunk_size<=0)
1.12      paf       184:                        break;
                    185:                read_size+=chunk_size;
                    186:        } while(read_size<max_bytes);
                    187: 
                    188:        return read_size;
1.10      paf       189: }
                    190: 
1.122     parser    191: void SAPI::add_header_attribute(Pool& , const char *key, const char *value) {
1.68      paf       192:        if(cgi)
1.20      paf       193:                printf("%s: %s\n", key, value);
1.19      paf       194: }
                    195: 
1.56      paf       196: /// @todo intelligent cache-control
1.122     parser    197: void SAPI::send_header(Pool& ) {
1.33      paf       198:        if(cgi) {
1.147     paf       199: //             puts("expires: Fri, 23 Mar 2001 09:32:23 GMT");
1.33      paf       200: 
                    201:                // header | body  delimiter
1.20      paf       202:                puts("");
1.33      paf       203:        }
1.30      paf       204: }
1.20      paf       205: 
1.122     parser    206: void SAPI::send_body(Pool& , const void *buf, size_t size) {
1.19      paf       207:        stdout_write(buf, size);
1.58      paf       208: }
                    209: 
1.97      parser    210: //
                    211: 
1.166     paf       212: void full_file_spec(const char *file_name, char *buf, size_t buf_size) {
1.167     paf       213:        if(file_name)
                    214:                if(file_name[0]=='/' 
                    215: #ifdef WIN32
                    216:                        || (file_name[0] && file_name[1]==':')
                    217: #endif
                    218:                        ) 
                    219:                        strncpy(buf, file_name, buf_size);
                    220:                else {
                    221:                        char cwd[MAX_STRING];  getcwd(cwd, MAX_STRING);
                    222:                        snprintf(buf, buf_size, "%s/%s", cwd, file_name);
                    223:                }
                    224:        else
                    225:                buf[0]=0;
1.166     paf       226: #ifdef WIN32
                    227:        back_slashes_to_slashes(buf);
                    228: #endif
1.97      parser    229: }
                    230: 
1.40      paf       231: /**
1.122     parser    232: main workhorse
1.19      paf       233: 
1.122     parser    234:   @todo 
1.40      paf       235:                IIS: remove trailing default-document[index.html] from $request.uri.
                    236:                to do that we need to consult metabase,
                    237:                wich is tested but seems slow.
1.144     paf       238:                IIS5 todo find out proper 'illegal call' check 
1.40      paf       239: */
1.122     parser    240: void real_parser_handler(
                    241:                                        const char *filespec_to_process,
                    242:                                        const char *request_method, bool header_only) {
                    243:        // init socks
1.178     paf       244:        init_socks(*pool);
1.122     parser    245:        
                    246:        // init global classes
1.178     paf       247:        init_methoded_array(*pool);
1.122     parser    248:        // init global variables
1.178     paf       249:        pa_globals_init(*pool);
1.122     parser    250:        
                    251:        if(!filespec_to_process)
1.144     paf       252:                SAPI::die("Parser/%s", PARSER_VERSION);
1.122     parser    253:        
                    254:        // Request info
                    255:        Request::Info request_info;
1.166     paf       256:        char document_root_buf[MAX_STRING];
1.122     parser    257:        if(cgi) {
1.178     paf       258:                if(const char *env_document_root=SAPI::get_env(*pool, "DOCUMENT_ROOT"))
1.122     parser    259:                        request_info.document_root=env_document_root;
1.178     paf       260:                else if(const char *path_info=SAPI::get_env(*pool, "PATH_INFO")) {
1.122     parser    261:                        // IIS
1.166     paf       262:                        size_t len=min(sizeof(document_root_buf)-1, strlen(filespec_to_process)-strlen(path_info));
                    263:                        memcpy(document_root_buf, filespec_to_process, len); document_root_buf[len]=0;
                    264:                        request_info.document_root=document_root_buf;
1.122     parser    265:                } else
1.165     paf       266:                        throw Exception("parser.runtime",
                    267:                                0,
                    268:                                "CGI: no PATH_INFO defined(in reinventing DOCUMENT_ROOT)");
1.122     parser    269:        } else {
1.166     paf       270:                full_file_spec("", document_root_buf, sizeof(document_root_buf));
                    271:                request_info.document_root=document_root_buf;
1.122     parser    272:        }
                    273:        request_info.path_translated=filespec_to_process;
                    274:        request_info.method=request_method ? request_method : "GET";
1.178     paf       275:        const char *query_string=SAPI::get_env(*pool, "QUERY_STRING");
1.122     parser    276:        request_info.query_string=query_string;
                    277:        if(cgi) {
1.178     paf       278:                if(const char *env_request_uri=SAPI::get_env(*pool, "REQUEST_URI"))
1.122     parser    279:                        request_info.uri=env_request_uri;
1.178     paf       280:                else if(const char *path_info=SAPI::get_env(*pool, "PATH_INFO"))
1.122     parser    281:                        if(query_string) {
1.178     paf       282:                                char *reconstructed_uri=(char *)pool->malloc(
1.122     parser    283:                                        strlen(path_info)+1/*'?'*/+
                    284:                                        strlen(query_string)+1/*0*/);
                    285:                                strcpy(reconstructed_uri, path_info);
                    286:                                strcat(reconstructed_uri, "?");
                    287:                                strcat(reconstructed_uri, query_string);
                    288:                                request_info.uri=reconstructed_uri;
                    289:                        } else
                    290:                                request_info.uri=path_info;
1.179     paf       291:                else
                    292:                        throw Exception("parser.runtime",
                    293:                                0,
                    294:                                "CGI: no PATH_INFO defined(in reinventing REQUEST_URI)");
1.145     paf       295:                        
                    296: #ifndef WIN32
                    297:                        // they've changed this under IIS5.
1.178     paf       298:                        if(const char *script_name=SAPI::get_env(*pool, "SCRIPT_NAME")) {
1.122     parser    299:                                size_t script_name_len=strlen(script_name);
                    300:                                size_t uri_len=strlen(request_info.uri);
                    301:                                if(strncmp(request_info.uri,script_name, script_name_len)==0 &&
                    302:                                        script_name_len != uri_len) // under IIS they are the same
1.144     paf       303:                                        SAPI::die("CGI: illegal call");
1.122     parser    304:                        }
1.145     paf       305: #endif
1.122     parser    306:        } else
1.177     paf       307:                request_info.uri="";
1.122     parser    308:        
1.178     paf       309:        request_info.content_type=SAPI::get_env(*pool, "CONTENT_TYPE");
                    310:        const char *content_length=SAPI::get_env(*pool, "CONTENT_LENGTH");
1.122     parser    311:        request_info.content_length=(content_length?atoi(content_length):0);
1.178     paf       312:        request_info.cookie=SAPI::get_env(*pool, "HTTP_COOKIE");
1.122     parser    313:        
                    314:        // prepare to process request
1.178     paf       315:        Request request(*pool,
1.122     parser    316:                request_info,
1.143     paf       317: #ifdef _DEBUG
                    318:                String::UL_HTML|String::UL_OPTIMIZE_BIT
                    319: #else
                    320:                cgi ? String::UL_HTML|String::UL_OPTIMIZE_BIT : String::UL_AS_IS
                    321: #endif
                    322:                ,
1.130     paf       323:                true /* status_allowed */);
1.122     parser    324:        
                    325:        // some root-controlled location
1.169     paf       326:        const char *root_config_filespec_cstr;
                    327:        char root_config_filespec_buf[MAX_STRING];
1.175     paf       328:        const char *root_config_by_env=getenv(PARSER_ROOT_CONFIG_ENV_NAME);
                    329:        if(!root_config_by_env)
                    330:                root_config_by_env=getenv(REDIRECT_PREFIX PARSER_ROOT_CONFIG_ENV_NAME);
                    331:        if(root_config_by_env)
1.169     paf       332:                root_config_filespec_cstr=root_config_by_env;
1.159     paf       333:        else {
1.152     paf       334: #ifdef ROOT_CONFIG_DIR
1.169     paf       335:                root_config_filespec_cstr=ROOT_CONFIG_DIR "/" CONFIG_FILE_NAME;
1.122     parser    336: #else
                    337: #      ifdef WIN32
1.159     paf       338:                // c:\windows
                    339:                char windows_dir[MAX_STRING];
                    340:                GetWindowsDirectory(windows_dir, MAX_STRING);
                    341: 
1.169     paf       342:                
                    343:                snprintf(root_config_filespec_buf, MAX_STRING, 
1.159     paf       344:                        "%s/%s", 
                    345:                        windows_dir, CONFIG_FILE_NAME);
                    346:                
1.169     paf       347:                root_config_filespec_cstr=root_config_filespec_buf;
1.122     parser    348: #      else
                    349: #error must be compiled either configure/make or MSVC++
                    350: #      endif
                    351: #endif
1.159     paf       352:        }
1.122     parser    353:        
1.169     paf       354:        const char *site_config_filespec_cstr;
                    355:        char site_config_filespec_buf[MAX_STRING];
1.175     paf       356:        const char *site_config_by_env=getenv(PARSER_SITE_CONFIG_ENV_NAME);
                    357:        if(!site_config_by_env)
                    358:                site_config_by_env=getenv(REDIRECT_PREFIX PARSER_SITE_CONFIG_ENV_NAME);
                    359:        if(site_config_by_env)
1.169     paf       360:                site_config_filespec_cstr=site_config_by_env;
1.164     paf       361:        else {
1.122     parser    362:        // beside by binary
                    363:        // @todo full path, not ./!
1.164     paf       364:                char beside_binary_path[MAX_STRING];
                    365:                strncpy(beside_binary_path, argv0, MAX_STRING-1);  beside_binary_path[MAX_STRING-1]=0; // filespec of my binary
                    366:                if(!(
                    367:                        rsplit(beside_binary_path, '/') || 
                    368:                        rsplit(beside_binary_path, '\\'))) { // strip filename
                    369:                        // no path, just filename
                    370:                        beside_binary_path[0]='.'; beside_binary_path[1]=0;
                    371:                }
1.169     paf       372:                snprintf(site_config_filespec_buf, MAX_STRING, 
1.164     paf       373:                        "%s/%s", 
                    374:                        beside_binary_path, CONFIG_FILE_NAME);
1.169     paf       375:                site_config_filespec_cstr=site_config_filespec_buf;
1.122     parser    376:        }
                    377:        
                    378:        // process the request
                    379:        request.core(
1.170     paf       380:                root_config_filespec_cstr, false /*fail_on_read_problem*/,
                    381:                site_config_filespec_cstr, false /*fail_on_read_problem*/,
1.122     parser    382:                header_only);
                    383:        
                    384:        //
                    385:        done_socks();
                    386:        
                    387: #ifdef DEBUG_POOL_MALLOC
                    388:        extern void log_pool_stats(Pool& pool);
1.178     paf       389:        log_pool_stats(*pool);
1.122     parser    390: #endif
1.160     paf       391: 
                    392: #ifdef DEBUG_STRING_APPENDS_VS_EXPANDS
1.178     paf       393:        SAPI::log(*pool, 
1.161     paf       394:                "string piece appends=%lu, wcontext_result_size=%lu, string_string_shortcut_economy_closer=%lu, total_alloc_size=%lu", 
1.160     paf       395:                string_piece_appends,
                    396:                wcontext_result_size,
                    397:                string_string_shortcut_economy,
                    398:                total_alloc_size);
                    399: #endif
                    400: 
1.122     parser    401: }
                    402: 
                    403: void call_real_parser_handler__do_SEH(
                    404:                                                                 const char *filespec_to_process,
                    405:                                                                 const char *request_method, bool header_only) {
1.133     paf       406: #if _MSC_VER && !defined(_DEBUG)
1.122     parser    407:        LPEXCEPTION_POINTERS system_exception=0;
                    408:        __try {
                    409: #endif
                    410:                real_parser_handler(
                    411:                        filespec_to_process,
                    412:                        request_method, header_only);
                    413:                
1.133     paf       414: #if _MSC_VER && !defined(_DEBUG)
1.122     parser    415:        } __except (
                    416:                (system_exception=GetExceptionInformation()), 
                    417:                EXCEPTION_EXECUTE_HANDLER) {
                    418:                
                    419:                if(system_exception)
                    420:                        if(_EXCEPTION_RECORD *er=system_exception->ExceptionRecord)
1.165     paf       421:                                throw Exception(0,
                    422:                                        0,
                    423:                                        "Exception 0x%08X at 0x%08X", er->ExceptionCode,  er->ExceptionAddress);
1.122     parser    424:                        else
1.165     paf       425:                                throw Exception(0, 0, "Exception <no exception record>");
1.122     parser    426:                        else
1.165     paf       427:                                throw Exception(0, 0, "Exception <no exception information>");
1.122     parser    428:        }
                    429: #endif
                    430: }
                    431: 
1.139     paf       432: #if _MSC_VER
1.135     paf       433: int failed_new(size_t size) {
                    434:        SAPI::die("out of memory in 'new', failed to allocated %u bytes", size);
                    435:        return 0; // not reached
1.131     paf       436: }
1.135     paf       437: #endif
1.131     paf       438: 
1.135     paf       439: #ifdef HAVE_SET_NEW_HANDLER
1.134     paf       440: void failed_new() {
1.135     paf       441:     SAPI::die("out of memory in 'new'");
1.131     paf       442: }
                    443: #endif
                    444: 
1.5       paf       445: int main(int argc, char *argv[]) {
1.178     paf       446:        Pool_storage global_pool_storage;
                    447:        Pool global_pool(&global_pool_storage);
                    448:        pool=&global_pool;
                    449: 
                    450: #ifdef _DEBUG
                    451: //     _crtBreakAlloc=33112;
                    452: #endif
1.144     paf       453: //     _asm int 3;
1.45      paf       454:        argv0=argv[0];
                    455: 
1.32      paf       456:        umask(2);
                    457: 
1.3       paf       458:        // were we started as CGI?
1.146     paf       459:        cgi=
1.109     parser    460:                getenv("SERVER_SOFTWARE") || 
                    461:                getenv("SERVER_NAME") || 
                    462:                getenv("GATEWAY_INTERFACE") || 
                    463:                getenv("REQUEST_METHOD");
1.5       paf       464:        
1.10      paf       465:        if(!cgi) {
                    466:                if(argc<2) {
1.69      paf       467:                        printf(
1.155     paf       468:                                "Parser/%s Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)\n"
1.154     paf       469:                                "Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)\n"
1.100     parser    470:                                "\n"
                    471:                                "Usage: %s <file>\n",
1.69      paf       472:                                PARSER_VERSION, 
                    473:                                argv0?argv0:"parser3");
1.67      paf       474:                        return 1;
1.10      paf       475:                }
                    476:        }
                    477: 
1.100     parser    478: #ifdef WIN32
                    479:        setmode(fileno(stdin), _O_BINARY);
                    480:        setmode(fileno(stdout), _O_BINARY);
                    481:        setmode(fileno(stderr), _O_BINARY);
                    482: #endif
                    483: 
1.139     paf       484: #if _MSC_VER
1.138     paf       485:        _set_new_handler(failed_new);
1.148     paf       486: 
                    487: #ifdef _DEBUG
                    488:        // Get current flag
                    489:        int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
                    490: 
                    491:        // Turn on leak-checking bit
                    492:        tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
                    493: 
                    494:        // Set flag to the new value
                    495:        _CrtSetDbgFlag( tmpFlag );
                    496: //     _CrtSetBreakAlloc(471);
                    497: 
                    498: #endif
                    499: 
1.138     paf       500: #endif
                    501: 
                    502: #ifdef HAVE_SET_NEW_HANDLER
                    503:        std::set_new_handler(failed_new);
                    504: #endif
                    505: 
1.166     paf       506:        char *raw_filespec_to_process=cgi?getenv("PATH_TRANSLATED"):argv[1];
                    507:        char filespec_to_process[MAX_STRING];
                    508:        full_file_spec(raw_filespec_to_process, filespec_to_process, sizeof(filespec_to_process));
1.10      paf       509: 
1.109     parser    510:        const char *request_method=getenv("REQUEST_METHOD");
1.35      paf       511:        bool header_only=request_method && strcasecmp(request_method, "HEAD")==0;
1.131     paf       512: 
1.122     parser    513:        try { // global try
                    514:                call_real_parser_handler__do_SEH(
                    515:                        filespec_to_process,
                    516:                        request_method, header_only);
                    517:        } catch(const Exception& e) { // global problem 
1.44      paf       518:                // don't allocate anything on pool here:
                    519:                //   possible pool' exception not catch-ed now
                    520:                //   and there could be out-of-memory exception
1.43      paf       521: 
1.144     paf       522:                SAPI::die("exception in request exception handler: %s", e.comment());
1.134     paf       523: #ifndef _DEBUG
1.131     paf       524:        } catch(...) { 
1.134     paf       525:                SAPI::die("<unknown exception>");
1.133     paf       526: #endif
1.16      paf       527:        }
1.122     parser    528:        
1.109     parser    529: 
                    530: #ifndef WIN32
                    531:        // 
                    532:        if(!cgi)
1.178     paf       533:                SAPI::send_body(*pool, "\n", 1);
1.109     parser    534: #endif
1.156     paf       535: //_asm int 3;
1.134     paf       536:        return 0;
1.1       paf       537: }

E-mail: