Extension Request Processing

When IIS receives a request for your ISAPI extension, it loads the DLL and calls the GetExtensionVersion entry point function. GetExtensionVersion returns a pointer to an HSE_VERSION_INFO structure. IIS then calls the HttpExtensionProc function with a pointer to an Extension_Control_Block (ECB) structure. Your extension processes the data contained in the ECB and uses the callback functions in ECB to write back responses to the client. When the extension is no longer needed, IIS calls the TerminateExtension function to unload the extension from memory.

After IIS finishes processing a request for an ISAPI, it can either close the connection or keep it open. A request can specify that the connection should remain open by specifying the Connection: Keep-Alive header. (With all HTTP 1.1 requests the Connection Keep-Alive header is included by default.) If you have designed your ISAPI extension to support Keep-Alive requests, you should indicate this to the client by calling the ServerSupporFunction and specifying the HSE_REQ_SEND_RESPONSE_HEADER value for the dwHSERequest parameter. The response header you specify should contain Connection: Keep-Alive. The following code demonstrates sending the Keep-Alive header:

DWORD 
SendHeaderToClient(
    LPEXTENSION_BLOCK pECB
    )
{
    BOOL fReturn;
    CHAR szHeader[256] = "";
    DWORD hseStatus = HSE_STATUS_SUCCESS;
 
    strcpy(szHeader, "Content-type: test/html\r\n\r\n");
    fReturn = 
    pECB->ServerSupportFunction(pECB->ConnID, 
                                HSE_REQ_SEND_RESPONSE_HEADER,
                                "Connection:Keep-Alive" // Telling the client not to close the connection
                                NULL,
                                (LPDWORD) szHeader);
 
    if (! fReturn ) {
        hseStatus = HSE_STATUS_ERROR;
    }
    return (hseStatus);
}
 

If the request has indicated that the connection should remain open, subsequent requests can be sequential or pipelined. When a client pipelines requests, it does not need to wait for earlier requests to be serviced before sending subsequent requests. IIS guarantees that pipelined requests will be returned to the client in the order they were received. IIS manages the ordering of request internally, so your extension does not need to add any special processing for pipelined requests.

For more details on pipelined requests, see RFC 2068 published by the World Wide Web consortium. RFC 2068 is available at http://www.isi.edu.