예제 #1
0
REQUEST_NOTIFICATION_STATUS CIISxpressHttpModule::OnBeginRequest(IN IHttpContext* pHttpContext, IN IHttpEventProvider* pProvider)
{
    UNREFERENCED_PARAMETER(pProvider);    		

	const TCHAR* const pszMethodName = __FUNCTIONT__;

	// startup the performance counters
	if (m_Config.GetPerfCountersEnabled() && m_pInstancePerfCounters.get() == NULL)
	{
		AutoMemberCriticalSection lock(&m_csPerfCounters);

		if (m_pInstancePerfCounters.get() == NULL)
		{
			CAtlString sAppName;
			GetAppPoolName(pHttpContext, sAppName);

			m_pInstancePerfCounters = auto_ptr<IISxpressNativePerf>(new IISxpressNativePerf(sAppName));			
		}

		// TODO: maybe one day get the global counters to work
		//if (m_pGlobalPerfCounters.get() == NULL)
		//{
		//	m_pGlobalPerfCounters = auto_ptr<IISxpressNativePerf>(new IISxpressNativePerf());
		//}
	}

	IHttpResponse* pHttpResponse = pHttpContext->GetResponse();
	if (pHttpResponse != NULL)
	{
		// Disable caching as HANDLER_HTTPSYS_UNFRIENDLY.
		// TODO: is this really a good idea?
		pHttpResponse->DisableKernelCache();
	}

	// get the registry settings (will only update every 5000ms as default)
	GetRegistrySettings(pHttpContext);

	// only proceed if filter is enabled
	if (m_Config.GetEnabled() == false)
	{
		AppendLogMessage(IISXPRESS_LOGGINGLEVEL_ENH, pszMethodName, pHttpContext, _T("module is disabled\n"));

		PerfCountersAddRejectedResponse(IISxpressNativePerf::FilterDisabled);

		// don't tell us about the send
		pHttpContext->DisableNotifications(RQ_SEND_RESPONSE, 0);
	}

    // Return processing to the pipeline.
    return RQ_NOTIFICATION_CONTINUE;
}