source:http://msdn.microsoft.com/en-us/library/ms524352.aspx
For an ISAPI extension to be used by IIS, it must provide a standard interface. To provide a standard interface, each ISAPI extension DLL must implement and export two primary functions, GetExtensionVersion and HttpExtensionProc. A third function, TerminateExtension, is optional and is commonly used by extensions to perform cleanup operations.
Initialization Using GetExtensionVersion
Initialization is handled by the entry-point function GetExtensionVersion. This function's role is to perform all initialization, including the creation of worker threads, synchronization objects, and database connections, and to establish the version of ISAPI that was used to build the DLL.
Adding Functionality Using HttpExtensionProc
In general, an extension's functionality is exposed through the
HttpExtensionProc entry-point function. This function receives a pointer to an
EXTENSION_CONTROL_BLOCK structure, which contains data used for the required processing and is also used by the extension to communicate with IIS.
When
HttpExtensionProc in employed, it should first
send a response header to the client. The header provides the client with information, such as the content type that is returned. After the header is sent, any other processing can be performed through the various callback functions provided in the
EXTENSION_CONTROL_BLOCK.
Termination Using TerminateExtension
When an extension is no longer needed, IIS removes it from memory. If the extension provides the TerminateExtension function, IIS calls it before removing the extension. Use of TerminateExtension is recommended to close down any threads that an extension initialized during processing.
After IIS finishes processing a request for an ISAPI extension, the connection can either be closed or kept open. A request can specify that the connection remain open by specifying the Connection: Keep-Alive header. If an ISAPI extension is designed to support Keep-Alive requests, this should be indicated to the client by calling the HSE_REQ_SEND_RESPONSE_HEADER server support function. The specified response header should contain Connection: Keep-Alive.
posted on 2010-01-12 09:15
黄剑父 阅读(257)
评论(0) 编辑 收藏 引用 所属分类:
C/C++