home *** CD-ROM | disk | FTP | other *** search
- // KeepAlive.c -> Sample ISAPI Extension demonstrating Keep-Alive
-
-
- #define _WIN32_WINNT 0x0400
-
-
- #include <windows.h>
- #include <httpext.h>
- #include <stdio.h>
-
-
- BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
- {
- pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
-
- lstrcpyn( pVer->lpszExtensionDesc,
- "ISAPI Keep-Alive Extension Sample",
- HSE_MAX_EXT_DLL_NAME_LEN );
-
- return TRUE;
- }
-
-
- DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
- {
- DWORD dwSize;
-
- // Use the "Connection: Keep-Alive" header to keep the connection open;
- // also, the "Content-Length:" header is required, so that the client knows when
- // the server has finished.
-
- char szHeader[] = "Connection: Keep-Alive\r\nContent-Length: %lu\r\nContent-type: text/html\r\n\r\n";
- char szContent[] = "<html> <form method=get action=KeepAlive.dll> <h1>Keep-Alive Sample</h1><hr>"
- "<input type=submit value=\"Send Request\"> </form></html>";
- char szBuffer[4096];
-
-
- // Send outgoing header with exact content length
-
- sprintf(szBuffer, szHeader, strlen(szContent));
- dwSize = strlen(szBuffer);
-
- pECB->ServerSupportFunction( pECB,
- HSE_REQ_SEND_RESPONSE_HEADER,
- NULL,
- &dwSize,
- (unsigned long *) szBuffer );
-
-
- // Send content
-
- dwSize = strlen(szContent);
-
- pECB->WriteClient( pECB,
- szContent,
- &dwSize,
- 0 );
-
-
- // This return code tells IIS not to close the socket connection.
-
- return HSE_STATUS_SUCCESS_AND_KEEP_CONN;
- }
-