Subj : ISAPI newbie question To : borland.public.cpp.borlandcpp From : "tim mackey" Date : Wed Jul 16 2003 03:45 am hi folks, this is my first post here. i'm trying to do a simple ISAPI url rewriter using borland C++. i don't have delphi or Visual Studio 6. the main idea is that i want to redirect all urls to /content.aspx, except the content.aspx page itself of course. i want to insert a http header called 'ORIGINAL_URL' which contains the original url. i found code from msdn which i have modified and pasted below, but i'm having trouble locating header files for it. code below. if there's any compile switches i should know about please let me know. i did manage to find the -WD switch for creating a DLL. any help is greatly appreciated! thanks tim mackey. // URLRewrite.cpp - Implementation file for ISAPI URLRewrite Filter #include "stdafx.h" #include "URLRewrite.h" // The one and only CWinApp object // NOTE: You may remove this object if you alter your project to no // longer use MFC in a DLL. CWinApp theApp; // The one and only CURLRewriteFilter object CURLRewriteFilter theFilter; // CURLRewriteFilter implementation CURLRewriteFilter::CURLRewriteFilter() { } CURLRewriteFilter::~CURLRewriteFilter() { } BOOL CURLRewriteFilter::GetFilterVersion(PHTTP_FILTER_VERSION pVer) { // Call default implementation for initialization CHttpFilter::GetFilterVersion(pVer); // Clear the flags set by base class pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK; // Set the flags we are interested in pVer->dwFlags |= SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_PREPROC_HEADERS; // Set Priority pVer->dwFlags |= SF_NOTIFY_ORDER_LOW; // Load description string TCHAR sz[SF_MAX_FILTER_DESC_LEN+1]; ISAPIVERIFY(::LoadString(AfxGetResourceHandle(), IDS_FILTER, sz, SF_MAX_FILTER_DESC_LEN)); _tcscpy(pVer->lpszFilterDesc, sz); return TRUE; } const DWORD cnURLSize = 4096; DWORD CURLRewriteFilter::OnPreprocHeaders(CHttpFilterContext* pfc, PHTTP_FILTER_PREPROC_HEADERS pHeaders) { // get the URL using the special "url" pseudoheader char lpszOriginalURL[cnURLSize], lpszNewUrl[cnURLSize]; DWORD nURLSize = cnURLSize; if ((pHeaders->GetHeader(pfc->m_pFC, "url", lpszOriginalURL, &nURLSize))) { // don't apply the filter to content.aspx if (strnicmp(lpszOriginalURL, "content.aspx", sizeof("content.aspx") - 1)) return CHttpFilter::OnPreprocHeaders(pfc, pHeaders); pHeaders->SetHeader(pfc->m_pFC, "ORIGINAL_URL:", (char*)lpszOriginalURL); pHeaders->SetHeader(pfc->m_pFC, "url", "/content.aspx"); } return CHttpFilter::OnPreprocHeaders(pfc, pHeaders); } // If your extension will not use MFC, you'll need this code to make // sure the extension objects can find the resource handle for the // module. If you convert your extension to not be dependent on MFC, // remove the comments around the following AfxGetResourceHandle() // and DllMain() functions, as well as the g_hInstance global. /* static HINSTANCE g_hInstance; HINSTANCE AFXISAPI AfxGetResourceHandle() { return g_hInstance; } BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, LPVOID lpReserved) { if (ulReason == DLL_PROCESS_ATTACH) { g_hInstance = hInst; } return TRUE; } */ ------------------------------- Tim Mackey www.ScootASP.net // .NET web hosting tim@scootasp.net ------------------------------- .