After IIS finishes processing a request for an ISAPI extension, 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. If you have designed your ISAPI extension to support Keep-Alive requests, you should indicate this to the client by calling the HSE_REQ_SEND_RESPONSE_HEADER ServerSupportFunction. The response header you specify should contain Connection: Keep-Alive.
Note If the request to IIS comes from a client browser that supports HTTP 1.1, such as Internet Explorer version 4.0 or later, and HTTP 1.1 is enabled, then HTTP connections will remain open by default. This is functionally equivalent to both the client and the server including Connection: Keep-Alive headers with every HTTP request and response.
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.w3.org/protocols.