日期:2014-05-16 浏览次数:21505 次
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <httpfilt.h> #include <iostream> #include <fstream> using namespace std; using namespace System; DWORD DoSendResponse(HTTP_FILTER_CONTEXT * pfc, HTTP_FILTER_SEND_RESPONSE * pResponse); BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer) { pVer->dwFlags = ( SF_NOTIFY_ORDER_DEFAULT | SF_NOTIFY_SEND_RESPONSE ); pVer->dwFilterVersion = HTTP_FILTER_REVISION; strcpy(pVer->lpszFilterDesc, "Replace Server Header ISAPI filter, Version 1.0"); return TRUE; } DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD NotificationType, VOID *pvData) { switch (NotificationType) { case SF_NOTIFY_SEND_RESPONSE : return DoSendResponse(pfc, (HTTP_FILTER_SEND_RESPONSE *) pvData); default : break; } return SF_STATUS_REQ_NEXT_NOTIFICATION; } DWORD DoSendResponse(HTTP_FILTER_CONTEXT * pfc,HTTP_FILTER_SEND_RESPONSE * pResponse) { System::IO::File::AppendAllText("c:\\abc.txt", "\r\n"); char PATH_TRANSLATED[1024]; DWORD cb; cb=sizeof(PATH_TRANSLATED); int len = 0; len = pfc->GetServerVariable(pfc, "PATH_TRANSLATED", PATH_TRANSLATED, &cb); String ^sPATH_TRANSLATED = gcnew String(PATH_TRANSLATED); System::IO::File::AppendAllText("c:\\abc.txt", sPATH_TRANSLATED); BOOL fServer = TRUE; DWORD dwServerError; fServer = pResponse->SetHeader(pfc, "Server:", "MyWebServer"); if ( !fServer ) { dwServerError = GetLastError(); pfc->pFilterContext = (LPVOID)(DWORD64)pResponse->HttpStatus; } return SF_STATUS_REQ_NEXT_NOTIFICATION; }