--- parser3/src/targets/isapi/parser3isapi.C 2001/03/24 11:33:29 1.15 +++ parser3/src/targets/isapi/parser3isapi.C 2001/04/03 07:20:55 1.22 @@ -15,8 +15,13 @@ #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") -//@{ -/// SAPI funcs decl +// SAPI + +/** + ISAPI SAPI functions receive this context information. + + @see Pool::set_context +*/ struct SAPI_func_context { LPEXTENSION_CONTROL_BLOCK lpECB; String *header; @@ -92,7 +97,7 @@ void SAPI::add_header_attribute(Pool& po } } -/// @todo intelligent cache-control +/// @todo parser4: intelligent cache-control void SAPI::send_header(Pool& pool) { SAPI_func_context& ctx=*static_cast(pool.context()); @@ -136,7 +141,21 @@ void SAPI::send_body(Pool& pool, const c ctx.lpECB->WriteClient(ctx.lpECB->ConnID, const_cast(buf), &num_bytes, HSE_IO_SYNC); } -//@} + +// goes to 'cs-uri-query' log file field. webmaster: switch it ON[default OFF]. +void SAPI::log(Pool& pool, const char *fmt, ...) { + SAPI_func_context& ctx=*static_cast(pool.context()); + + va_list args; + va_start(args,fmt); + char buf[MAX_STRING]; + const char *prefix="PARSER_ERROR:"; + strcpy(buf, prefix); + DWORD size=vsnprintf(buf+strlen(prefix), MAX_STRING-strlen(prefix), fmt, args); + + ctx.lpECB->ServerSupportFunction(ctx.lpECB->ConnID, + HSE_APPEND_LOG_PARAMETER, buf, &size, 0); +} // @@ -172,7 +191,7 @@ BOOL WINAPI GetExtensionVersion(HSE_VERS /** ISAPI // main workhorse - @todo + @todo parser4: 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 runtime @@ -183,8 +202,8 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI Pool pool(&pool_storage); // no allocations until assigned context [for reporting] SAPI_func_context ctx={ lpECB, - 0, // filling later: so that if there would be error pool would have ctx - 200 + 0, // filling later: so that if there would be error pool would have ctx + 200 }; pool.set_context(&ctx);// no allocations before this line! @@ -231,6 +250,8 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI request_info.content_type=lpECB->lpszContentType; request_info.content_length=lpECB->cbTotalBytes; request_info.cookie=SAPI::get_env(pool, "HTTP_COOKIE"); + request_info.user_agent=SAPI::get_env(pool, "HTTP_USER_AGENT"); + // prepare to process request Request request(pool, @@ -256,6 +277,10 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI // possible pool' exception not catch-ed now // and there could be out-of-memory exception const char *body=e.comment(); + // log it + SAPI::log(pool, "exception in request exception handler: %s", body); + + // int content_length=strlen(body); // prepare header // not using SAPI func wich allocates on pool @@ -289,22 +314,3 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSI return HSE_STATUS_SUCCESS_AND_KEEP_CONN; } - -/* -BOOL APIENTRY DllMain(HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) { - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH: - break; - case DLL_THREAD_ATTACH: - break; - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -*/ \ No newline at end of file