Converting Existing CGI Scripts to ISAPI Extensions
This section explains the basic requirements for converting existing CGI script-executable files to ISAPI extension DLLs. As with other DLLs, Web server applications should be thread-safe. More than one client will be executing the same function at the same time, so the code should follow safety procedures in modifying a global or static variable.
You can keep your ISAPI extension thread-safe by using appropriate synchronization techniques, such as creating critical sections and semaphores. For additional information on writing thread-safe DLLs, see the documentation in the Platform SDK and in the Microsoft Development Library compact disc.
There are several structural differences between an ISAPI extension and a CGI executable file. An ISAPI extension:
-
Receives most of its data through the lpbData member of the Extension Control Block (ECB) as opposed to reading it from stdin. For any additional data, the extension uses the ReadClient callback function.
-
Accesses common CGI variables through the ECB. For other variables, it calls GetServerVariable. In a CGI executable file, these are retrieved from the environment table using getenv.
-
Sends data back to the client with the WriteClient callback function instead of writing to stdout.
-
Specifies completion status by either sending the header directly using the WriteClient callback function, or calls ServerSupportFunction using the HSE_REQ_SEND_RESPONSE_HEADER, instead of sending a "Status: NNN xxxxx..." to stdout.
-
Redirects requests with a Location: or URL: header, instead of writing the header to stdout, use the HSE_REQ_SEND_URL if the URL is local. However, if the URL is remote or unknown, HSE_REQ_SEND_URL_REDIRECT_RESP in the ServerSupportFunction callback function is used.