|
|
|
date: Thu, 18 Oct 2007 16:58:03 -0700,
group: microsoft.public.platformsdk.internet.server.isapi-dev
back
Re: HttpFilterProc not being called
David,
Thanks much for your input. I am using Windows XP Professional SP2 with IIS
5.1.
Could you tell me how I set the filter to be global or site filter?
Basically, I installed my filter in Default Web Site and created a simple
.htm page to test the filter.
In Properties | ISAPI Filter, it shows a green arrow.
I make a request http://mycomputer/Test.htm. The test page is displayed,
but HttpFilterProc isn't called. I know GetFilterVersion is called.
What am I doing wrong?
--
Be Cool!
"David Wang" wrote:
> On Oct 18, 4:58 pm, thejackofall
> wrote:
> > Hi.
> >
> > I wrote a ISAPI filter. It's loaded fine because there are no errors in the
> > event viewer. However, HttpFilterProc is not called it seems. When I put
> > logging code in GetFilterVersion, it logs as I expected.
> >
> > Please help.
> >
> > --
> > Be Cool!
>
>
> Did you make a request within the configured scope of the ISAPI
> Filter?
>
> FYI: "No errors in the event viewer" does not mean "it's loaded fine".
> Depending on IIS version and whether the filter is global/site, filter
> DLL may not dynamically load and thus lack of errors in event viewer
> does not mean it's loaded fine. It may not have loaded at all.
>
>
> //David
> http://w3-4u.blogspot.com
> http://blogs.msdn.com/David.Wang
> //
>
>
date: Fri, 19 Oct 2007 11:23:04 -0700
author: thejackofall
Re: HttpFilterProc not being called
There are lots of ways for a filter to be loaded (GetFilterVersion is
called) but not executed (HttpFilterProc is not called).
You have not indicated whether your filter is configured as global or
site filter, IIS version, nor whether you've made a request and if so,
the exact URL. I'm not sure how anyone can help you without that
information.
Also, please identify the exact action you have done which you think
*should* invoke HttpFilterProc but did not, and why.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
On Oct 19, 9:32 am, thejackofall
wrote:
> David,
>
> I am not exactly sure what you mean by "a request within the configured
> scope", but I have the following in GetFilterVersion.
>
> pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_ORDER_DEFAULT |
> SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_SEND_RAW_DATA);
>
> Thanks.
> J
>
> --
> Be Cool!
>
>
>
> "David Wang" wrote:
> > On Oct 18, 4:58 pm, thejackofall
> > wrote:
> > > Hi.
>
> > > I wrote a ISAPI filter. It's loaded fine because there are no errors in the
> > > event viewer. However, HttpFilterProc is not called it seems. When I put
> > > logging code in GetFilterVersion, it logs as I expected.
>
> > > Please help.
>
> > > --
> > > Be Cool!
>
> > Did you make a request within the configured scope of the ISAPI
> > Filter?
>
> > FYI: "No errors in the event viewer" does not mean "it's loaded fine".
> > Depending on IIS version and whether the filter is global/site, filter
> > DLL may not dynamically load and thus lack of errors in event viewer
> > does not mean it's loaded fine. It may not have loaded at all.
>
> > //David
> >http://w3-4u.blogspot.com
> >http://blogs.msdn.com/David.Wang
> > //- Hide quoted text -
>
> - Show quoted text -
date: Fri, 19 Oct 2007 11:33:04 -0700
author: David Wang
Re: HttpFilterProc not being called
I am using Windows XP Professional SP2 with IIS 5.1.
The filter is installed correctly and HttpFilterProc is getting called.
Basically, I installed my filter in Default Web Site and created a simple
.htm page to test the filter. In Default Web Site | Properties | ISAPI
Filter, it shows a green arrow.
Now, the filter is being called, but I see that IIS is not happy because I
see the following in my debug file.
Hello World!
SF_NOTIFY_SEND_RAW_DATA
pfc->pFilterContext
Daata: HTTP/1.1 304 Not Modified
Server: Microsoft-IIS/5.1
Date: Fri, 19 Oct 2007 19:02:52 GMT
ETag: "4aef212cd011c81:c3f"
Content-Length: 0
IIS http://www.intel.com
Here is my code.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <httpfilt.h>
#include <string>
#include <map>
#include <fstream>
#include <iostream>
using std::string;
using std::ifstream;
using std::ios;
using std::iterator;
using std::ofstream;
using std::endl;
typedef std::map<string, string> KeywordURL;
KeywordURL Keywords;
BOOL LoadData()
{
ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
string sKeyword;
string sURL;
if (fData)
{
while (fData >> sKeyword >> sURL)
{
Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
}
}
fData.close();
return TRUE;
}
BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
{
// Specify the types and order of notification
// pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
| SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_ORDER_DEFAULT |
SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_SEND_RAW_DATA);
pVer->dwFilterVersion = HTTP_FILTER_REVISION;
strcpy(pVer->lpszFilterDesc, "MyFilter, Version 1.0");
// Load keywords
LoadData();
return TRUE;
}
DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
NotificationType, VOID *pvData)
{
CHAR * pchIn;
DWORD cbBuffer, cbtemp;
PHTTP_FILTER_RAW_DATA pRawData;
ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
fDebug << "Hello World!" << endl;
switch (NotificationType)
{
case SF_NOTIFY_SEND_RAW_DATA :
{
fDebug << "SF_NOTIFY_SEND_RAW_DATA" << endl;
//if (pfc->pFilterContext)
//{
fDebug << "pfc->pFilterContext" << endl;
pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
pchIn = (CHAR *) pRawData->pvInData;
cbBuffer = 0;
/*if (pfc->pFilterContext == (VOID *) 1)
{
//As this is the first block, scan through it until 2 CRLFs are seen,
to pass
//all of the headers.
for ( ; cbBuffer < pRawData->cbInData - 2; cbBuffer++)
{
if (pchIn[cbBuffer] == '\n' && pchIn[cbBuffer + 2] == '\n')
{
cbBuffer += 3;
break;
}
cbBuffer++;
}
for (cbtemp = 0; cbtemp < (cbBuffer - 3); cbtemp++)
{
if (pchIn[cbtemp] == '/' && pchIn[cbtemp + 1] == 'h' && pchIn[cbtemp +
2] == 't' && pchIn[cbtemp + 3] == 'm')
{
pfc->pFilterContext = (VOID *) 2;
break;
}
}
joon: comment out here because we want any file
if (cbtemp == cbBuffer)
pfc->pFilterContext = 0; not an html file
} */
/* Now uppercase everything */
//if (pfc->pFilterContext)
//{
// joon: The below 2 lines are original
//for ( ; cbBuffer < pRawData->cbInData; cbBuffer++)
// pchIn[cbBuffer] = (pchIn[cbBuffer] >= 'a' && pchIn[cbBuffer] <= 'z')
? (pchIn[cbBuffer] - 'a' + 'A') : pchIn[cbBuffer];
CHAR * pchInTemp = (CHAR *) pfc->AllocMem(pfc, pRawData->cbInBuffer *
2, NULL);
memset(pchInTemp, '0', pRawData->cbInBuffer * 2);
strcpy(pchInTemp, (CHAR *) pRawData->pvInData);
string sInTemp(pchInTemp);
fDebug << "Daata: " << sInTemp << endl;
int iInData = pRawData->cbInData;
int iIndex = 0;
for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator
!= Keywords.end(); ++iterator)
{
fDebug << iterator->first << ' ' << iterator->second << endl;
iIndex = sInTemp.find(iterator->first);
while (iIndex != string::npos)
{
string sAnchor("<a href=""" + iterator->second + """>" +
iterator->first + "</a>");
sInTemp = sInTemp.replace(iIndex, iIndex + sAnchor.length(), sAnchor);
iInData = iInData + iterator->second.length() + 15;
iIndex = sInTemp.find(iterator->first);
}
}
pRawData->pvInData = (VOID *) sInTemp.c_str();
pRawData->cbInBuffer = strlen(sInTemp.c_str());
pRawData->cbInData = iInData;
/*CHAR sHeader[20];
memset(sHeader, '0', 20);
strcpy(sHeader, "Content-Length: ");
CHAR sLength[10];
memset(sLength, '0', 10);
itoa(iInData, sLength, 10);
strcat(sHeader, sLength);
pfc->AddResponseHeaders(pfc, sHeader, 0);*/
//}
//}
break;
}
default :
break;
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
--
Be Cool!
"David Wang" wrote:
> There are lots of ways for a filter to be loaded (GetFilterVersion is
> called) but not executed (HttpFilterProc is not called).
>
> You have not indicated whether your filter is configured as global or
> site filter, IIS version, nor whether you've made a request and if so,
> the exact URL. I'm not sure how anyone can help you without that
> information.
>
> Also, please identify the exact action you have done which you think
> *should* invoke HttpFilterProc but did not, and why.
>
>
> //David
> http://w3-4u.blogspot.com
> http://blogs.msdn.com/David.Wang
> //
>
>
>
>
>
>
> On Oct 19, 9:32 am, thejackofall
> wrote:
> > David,
> >
> > I am not exactly sure what you mean by "a request within the configured
> > scope", but I have the following in GetFilterVersion.
> >
> > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_ORDER_DEFAULT |
> > SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_SEND_RAW_DATA);
> >
> > Thanks.
> > J
> >
> > --
> > Be Cool!
> >
> >
> >
> > "David Wang" wrote:
> > > On Oct 18, 4:58 pm, thejackofall
> > > wrote:
> > > > Hi.
> >
> > > > I wrote a ISAPI filter. It's loaded fine because there are no errors in the
> > > > event viewer. However, HttpFilterProc is not called it seems. When I put
> > > > logging code in GetFilterVersion, it logs as I expected.
> >
> > > > Please help.
> >
> > > > --
> > > > Be Cool!
> >
> > > Did you make a request within the configured scope of the ISAPI
> > > Filter?
> >
> > > FYI: "No errors in the event viewer" does not mean "it's loaded fine".
> > > Depending on IIS version and whether the filter is global/site, filter
> > > DLL may not dynamically load and thus lack of errors in event viewer
> > > does not mean it's loaded fine. It may not have loaded at all.
> >
> > > //David
> > >http://w3-4u.blogspot.com
> > >http://blogs.msdn.com/David.Wang
> > > //- Hide quoted text -
> >
> > - Show quoted text -
>
>
>
date: Fri, 19 Oct 2007 13:36:01 -0700
author: thejackofall
Re: HttpFilterProc not being called
Please be consistent with your questions.
You first said HttpFilterProc was not being called. Then you show your
ISAPI Filter causing IIS to return a malformed HTTP response and say
that IIS isn't happy with it (so HttpFilterProc is called).
Actually, IIS is perfectly happy. It's the client that won't like the
malformed HTTP response and hang.
What are you trying to do.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
On Oct 19, 1:36 pm, thejackofall
wrote:
> I am using Windows XP Professional SP2 with IIS 5.1.
>
> The filter is installed correctly and HttpFilterProc is getting called.
> Basically, I installed my filter in Default Web Site and created a simple
> .htm page to test the filter. In Default Web Site | Properties | ISAPI
> Filter, it shows a green arrow.
>
> Now, the filter is being called, but I see that IIS is not happy because I
> see the following in my debug file.
>
> Hello World!
> SF_NOTIFY_SEND_RAW_DATA
> pfc->pFilterContext
> Daata: HTTP/1.1 304 Not Modified
> Server: Microsoft-IIS/5.1
> Date: Fri, 19 Oct 2007 19:02:52 GMT
> ETag: "4aef212cd011c81:c3f"
> Content-Length: 0
>
> IIShttp://www.intel.com
>
> Here is my code.
>
> #include <windows.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <httpfilt.h>
>
> #include <string>
> #include <map>
> #include <fstream>
> #include <iostream>
>
> using std::string;
> using std::ifstream;
> using std::ios;
> using std::iterator;
> using std::ofstream;
> using std::endl;
>
> typedef std::map<string, string> KeywordURL;
>
> KeywordURL Keywords;
>
> BOOL LoadData()
> {
> ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> string sKeyword;
> string sURL;
>
> if (fData)
> {
> while (fData >> sKeyword >> sURL)
> {
> Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> }
> }
>
> fData.close();
>
> return TRUE;
>
> }
>
> BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> {
> // Specify the types and order of notification
> // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_ORDER_DEFAULT |
> SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_SEND_RAW_DATA);
> pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> strcpy(pVer->lpszFilterDesc, "MyFilter, Version 1.0");
>
> // Load keywords
> LoadData();
>
> return TRUE;
>
> }
>
> DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> NotificationType, VOID *pvData)
> {
> CHAR * pchIn;
> DWORD cbBuffer, cbtemp;
> PHTTP_FILTER_RAW_DATA pRawData;
>
> ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> fDebug << "Hello World!" << endl;
>
> switch (NotificationType)
> {
> case SF_NOTIFY_SEND_RAW_DATA :
> {
> fDebug << "SF_NOTIFY_SEND_RAW_DATA" << endl;
> //if (pfc->pFilterContext)
> //{
> fDebug << "pfc->pFilterContext" << endl;
> pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> pchIn = (CHAR *) pRawData->pvInData;
> cbBuffer = 0;
>
> /*if (pfc->pFilterContext == (VOID *) 1)
> {
> //As this is the first block, scan through it until 2 CRLFs are seen,
> to pass
> //all of the headers.
>
> for ( ; cbBuffer < pRawData->cbInData - 2; cbBuffer++)
> {
> if (pchIn[cbBuffer] == '\n' && pchIn[cbBuffer + 2] == '\n')
> {
> cbBuffer += 3;
> break;
> }
>
> cbBuffer++;
> }
>
> for (cbtemp = 0; cbtemp < (cbBuffer - 3); cbtemp++)
> {
> if (pchIn[cbtemp] == '/' && pchIn[cbtemp + 1] == 'h' && pchIn[cbtemp +
> 2] == 't' && pchIn[cbtemp + 3] == 'm')
> {
> pfc->pFilterContext = (VOID *) 2;
> break;
> }
> }
>
> joon: comment out here because we want any file
> if (cbtemp == cbBuffer)
> pfc->pFilterContext = 0; not an html file
> } */
>
> /* Now uppercase everything */
>
> //if (pfc->pFilterContext)
> //{
> // joon: The below 2 lines are original
> //for ( ; cbBuffer < pRawData->cbInData; cbBuffer++)
> // pchIn[cbBuffer] = (pchIn[cbBuffer] >= 'a' && pchIn[cbBuffer] <= 'z')
> ? (pchIn[cbBuffer] - 'a' + 'A') : pchIn[cbBuffer];
>
> CHAR * pchInTemp = (CHAR *) pfc->AllocMem(pfc, pRawData->cbInBuffer *
> 2, NULL);
> memset(pchInTemp, '0', pRawData->cbInBuffer * 2);
> strcpy(pchInTemp, (CHAR *) pRawData->pvInData);
> string sInTemp(pchInTemp);
> fDebug << "Daata: " << sInTemp << endl;
> int iInData = pRawData->cbInData;
> int iIndex = 0;
>
> for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator
> != Keywords.end(); ++iterator)
> {
> fDebug << iterator->first << ' ' << iterator->second << endl;
> iIndex = sInTemp.find(iterator->first);
>
> while (iIndex != string::npos)
> {
> string sAnchor("<a href=""" + iterator->second + """>" +
> iterator->first + "</a>");
> sInTemp = sInTemp.replace(iIndex, iIndex + sAnchor.length(), sAnchor);
> iInData = iInData + iterator->second.length() + 15;
>
> iIndex = sInTemp.find(iterator->first);
> }
> }
>
> pRawData->pvInData = (VOID *) sInTemp.c_str();
> pRawData->cbInBuffer = strlen(sInTemp.c_str());
> pRawData->cbInData = iInData;
>
> /*CHAR sHeader[20];
> memset(sHeader, '0', 20);
> strcpy(sHeader, "Content-Length: ");
>
> CHAR sLength[10];
> memset(sLength, '0', 10);
> itoa(iInData, sLength, 10);
>
> strcat(sHeader, sLength);
>
> pfc->AddResponseHeaders(pfc, sHeader, 0);*/
> //}
> //}
>
> break;
> }
> default :
> break;
> }
>
> return SF_STATUS_REQ_NEXT_NOTIFICATION;
>
> }
>
> --
> Be Cool!
>
>
>
> "David Wang" wrote:
> > There are lots of ways for a filter to be loaded (GetFilterVersion is
> > called) but not executed (HttpFilterProc is not called).
>
> > You have not indicated whether your filter is configured as global or
> > site filter, IIS version, nor whether you've made a request and if so,
> > the exact URL. I'm not sure how anyone can help you without that
> > information.
>
> > Also, please identify the exact action you have done which you think
> > *should* invoke HttpFilterProc but did not, and why.
>
> > //David
> >http://w3-4u.blogspot.com
> >http://blogs.msdn.com/David.Wang
> > //
>
> > On Oct 19, 9:32 am, thejackofall
> > wrote:
> > > David,
>
> > > I am not exactly sure what you mean by "a request within the configured
> > > scope", but I have the following in GetFilterVersion.
>
> > > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_ORDER_DEFAULT |
> > > SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_SEND_RAW_DATA);
>
> > > Thanks.
> > > J
>
> > > --
> > > Be Cool!
>
> > > "David Wang" wrote:
> > > > On Oct 18, 4:58 pm, thejackofall
> > > > wrote:
> > > > > Hi.
>
> > > > > I wrote a ISAPI filter. It's loaded fine because there are no errors in the
> > > > > event viewer. However, HttpFilterProc is not called it seems. When I put
> > > > > logging code in GetFilterVersion, it logs as I expected.
>
> > > > > Please help.
>
> > > > > --
> > > > > Be Cool!
>
> > > > Did you make a request within the configured scope of the ISAPI
> > > > Filter?
>
> > > > FYI: "No errors in the event viewer" does not mean "it's loaded fine".
> > > > Depending on IIS version and whether the filter is global/site, filter
> > > > DLL may not dynamically load and thus lack of errors in event viewer
> > > > does not mean it's loaded fine. It may not have loaded at all.
>
> > > > //David
> > > >http://w3-4u.blogspot.com
> > > >http://blogs.msdn.com/David.Wang
> > > > //- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
date: Sat, 20 Oct 2007 04:19:55 -0000
author: David Wang
|
|