Thanks, Anthony.
The reason I use the string type is because I do keyword replacements, and
the best way to do that is to use the string type which gives me find() with
other string manipulations.
Here is my code.
DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
NotificationType, VOID *pvData)
{
PHTTP_FILTER_RAW_DATA pRaw = NULL;
switch (NotificationType)
{
case SF_NOTIFY_SEND_RAW_DATA:
{
pRaw = (PHTTP_FILTER_RAW_DATA) pvData;
string sDataTemp((CHAR*) pRaw->pvInData, pRaw->cbInData);
AutoLinkContext* pALC = (AutoLinkContext*) pfc->pFilterContext;
int iPosition1 = sDataTemp.find("Content-Length:");
if (pALC == NULL && iPosition1 != string::npos)
{
int iPosition2 = sDataTemp.find("\r\n\r\n");
if (iPosition2 != string::npos)
{
pALC = new AutoLinkContext();
if (pALC != NULL)
{
pALC->iSent = 0;
pALC->sContentLength = sDataTemp.substr(iPosition1 + 16, iPosition2 -
(iPosition1 + 16));
pALC->sHeader.resize(sDataTemp.length());
sDataTemp.copy((LPSTR) pALC->sHeader.c_str(), sDataTemp.length());
pfc->pFilterContext = pALC;
}
pRaw->cbInData = 0;
pRaw->pvInData = NULL;
}
}
else if (pALC != NULL && pALC->iSent == 0)
{
pALC->sData.replace(pALC->sData.length(), sDataTemp.length(), sDataTemp);
pRaw->cbInData = 0;
pRaw->pvInData = NULL;
}
break;
}
case SF_NOTIFY_END_OF_REQUEST:
{
AutoLinkContext* pALC = (AutoLinkContext*) pfc->pFilterContext;
if (pALC != NULL)
{
string sNewContentLength;
sNewContentLength.resize(pALC->sContentLength.length());
itoa(pALC->sData.length(), (LPSTR) sNewContentLength.c_str(), 10);
int iPosition = pALC->sHeader.find("Content-Length:") + 16;
pALC->sHeader.replace(iPosition, sNewContentLength.length(),
sNewContentLength);
pALC->sHeader.append("\r\n");
pALC->sHeader.replace(pALC->sHeader.length(), pALC->sData.length(),
pALC->sData);
pALC->iSent = 1;
DWORD dwData = (DWORD) ((int) pALC->sHeader.length());
pfc->WriteClient(pfc, (LPVOID) pALC->sHeader.c_str(), &dwData, 0);
}
break;
}
case SF_NOTIFY_END_OF_NET_SESSION:
{
if (pfc != NULL)
{
AutoLinkContext* pALC = (AutoLinkContext*) pfc->pFilterContext;
if (pALC != NULL)
{
pALC->iSent = 1;
pALC->sData.clear();
pALC->sContentLength.clear();
pALC->sHeader.clear();
pALC = NULL;
}
}
break;
}
default:
break;
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
--
Be Cool!
"Anthony Jones" wrote:
> "thejackofall" <thejackofall.DeleteThis@discussions.microsoft.com> wrote in message
> news:EB82B249-2C94-41E4-83BE-C31308388E0F@microsoft.com...
> > I wrote an ISAPI filter that collects and modifies the data before sending
> it
> > down to the browser, including the images.
> >
> > The image shows fine in FireFox, but it's shows the X image marker in IE
> > instead of the image. When I save the data to a file and open it, I
> > noticed the image binary is cut off by what I think is a carriage return
> or
> > new line character. In my code, I collect the data in the string type in
> > C++.
> >
> > Has anyone experienced this problem? If you have a solution, please let
> me > know.
> >
>
>
> It would help if you posted some code, although using a 'string' type to
> hold binary data doesn't sound too sensible when C++ gives you plenty of
> other options.
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
> >> Stay informed about: Image in FireFox is fine, but not in IE