--- parser3/src/targets/isapi/parser3isapi.C 2001/03/23 13:27:56 1.11 +++ parser3/src/targets/isapi/parser3isapi.C 2001/03/23 19:25:18 1.13 @@ -11,6 +11,7 @@ #include "pa_globals.h" #include "pa_request.h" #include "pa_version.h" +#include "pool_storage.h" #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") @@ -96,7 +97,7 @@ void SAPI::send_header(Pool& pool) { sapi_func_context& ctx=*static_cast(pool.context()); ctx.header->APPEND_CONST( - "Expires: Fri, 23 Mar 2001 09:32:23 GMT\n" + "expires: Fri, 23 Mar 2001 09:32:23 GMT\n" "\n"); HSE_SEND_HEADER_EX_INFO header_info; @@ -145,7 +146,7 @@ static void parser_init() { return; globals_inited=true; - static Pool pool; // global pool + static Pool pool(0); // global pool PTRY { // init global variables pa_globals_init(pool); @@ -171,19 +172,22 @@ BOOL WINAPI GetExtensionVersion(HSE_VERS @todo IIS: remove trailing default-document[index.html] from $request.uri. to do that we need to consult metabase, - wich is tested&works but seems slow. + wich is tested&works but seems slow runtime + and not could-be-quickly-implemented if prepared. */ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) { - Pool pool; + Pool_storage pool_storage; + Pool pool(&pool_storage); bool header_only=strcasecmp(lpECB->lpszMethod, "HEAD")==0; PTRY { // global try sapi_func_context ctx={ lpECB, - new(pool) String(pool), + 0, // filling later: so that if there would be error pool would have ctx 200 }; pool.set_context(&ctx); + ctx.header=new(pool) String(pool); // Request info Request::Info request_info; @@ -237,27 +241,40 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI root_auto_path, false/*may be abcent*/, // /path/to/admin/auto.p 0/*parser_site_auto_path*/, false, // /path/to/site/auto.p header_only); - // successful finish - } PCATCH(e) { // global problem + } PCATCH(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 const char *body=e.comment(); int content_length=strlen(body); - // prepare header - SAPI::add_header_attribute(pool, "content-type", "text/plain"); - char content_length_cstr[MAX_NUMBER]; - snprintf(content_length_cstr, MAX_NUMBER, "%lu", content_length); - SAPI::add_header_attribute(pool, "content-length", content_length_cstr); - + // prepare header // not using SAPI func wich allocates on pool + char header_buf[MAX_STRING]; + int header_len=snprintf(header_buf, MAX_STRING, + "content-type: text/plain\n" + "content-length: %ul\n" + "expires: Fri, 23 Mar 2001 09:32:23 GMT\n" + "\n", + content_length); + + HSE_SEND_HEADER_EX_INFO header_info; + header_info.pszStatus="200 OK"; + header_info.cchStatus=strlen(header_info.pszStatus); + header_info.pszHeader=header_buf; + header_info.cchHeader=header_len; + header_info.fKeepConn=true; + // send header - SAPI::send_header(pool); + lpECB->dwHttpStatusCode=200; + lpECB->ServerSupportFunction(lpECB->ConnID, + HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); // send body if(!header_only) SAPI::send_body(pool, body, content_length); // unsuccessful finish - _endthread(); } PEND_CATCH