ExampleTable of ContentsDelphi Install
OnSendRawData Example

ISAPI Filter SF_NOTIFY_SEND_RAW_DATA Example

TbcISAPIFilter Component comes with a working example of handling SEND_RAW_DATA notifications from IIS.

Introduction on SEND_RAW_DATA notification

IIS uses the SF_NOTIFY_SEND_RAW_DATA notifications to give filters a last chance to modify content as it is being sent out to the client. This notification type is useful if you wish to modify the outgoing data on the fly. For example, you can have ${myvar} kind of variables to be replaced in your html content: ${admin.email}, ${author.address} etc which you can replace in your filter. Or, for example, original content can be XML and you can transform it to HTML using XSLT and then send the result to the browser. You get to have total control and the final say when you handle SF_NOTIFY_SEND_RAW_DATA notifications using OnSendRawData event handlers in TbcISAPIFilter component.

About the Example Filter in TbcISAPIFilter package

bcSendRawDataFilter.dll is an example filter included with TbcISAPIFilter component. This example illustrates the following points about writing filters:

  1. Using multiple handler functions to process a single process
    • OnSendRawData
    • OnSendResponse
    • OnUrlMap
  2. Coordinating these handler functions for a single purpose using
    • Thread Local variables
    • ISAPI Filter Context (pfcObject.m_pFC.pFilterContext)
  3. How IIS data structures are passed into these event handlers and how they are used
  4. How to run the filter for individual virtual hosts (If a filter handles SEND_RAW_DATA notifications, it MUST be installed as a global filter in IIS, thus you need to decide programmatically if you do not want your filter invoked for some websites)
  5. How to log actions for debugging and support purposes

NOTE: Most examples out there in the internet assume one notification of SEND_RAW_DATA is sufficient to send full content of an html page. This is not true if your page is big. IIS chunks the data as it is being sent out and your OnSendRawData handler can be called multiple times to process the outgoing content in smaller chunks. You may need to make changes in each of the outgoing chunks, but one of the many challenges is: You have sent the Content-Length HTTP header in the first chunk, now if you modify rest of the data, how can the length of the data you are actually sending match the content-length you have already sent to the client?

Answer is within your reach! Buy TbcISAPIFilter Component Now!

webmaster@bestcode.com