|
htmlISAPI
ISAPI server interface class | [Previous] [Main] [Next] |
| Like htmlCgi, htmlISAPI inherits from htmlServer, providing support for interfacing to ISAPI compliant web servers such as Microsoft IIS, and making it easy to pass data such as form fields, and even entire files, to and from web browsers.
| |
|
| |
| Unlike CGI applications, ISAPI applications run in the same address space as the web server and thus have lower overhead and generally faster execution. The htmlISAPI constructor accepts a EXTENSION_CONTROL_BLOCK pointer, provided by the ISAPI server. Under Windows, this pointer is passed to the application's DLL entry point routine HttpExtensionProc().
| |
|
| |
| With the exception of the constructor and the Initialize() method, htmlISAPI is identical in behavior to its htmlServer parent class. For additional details, please refer to the documentation for htmlServer.
| |
|
| |
| #include <dcmicro/htmlpp/cisapi.h>
| |
|
| |
| |
|
| |
| htmlServer, htmlCgi, CNVList, htmlForm, htmlInputHidden
| |
|
| |
| None.
| |
|
| |
| htmlISAPI()
| |
| Constructs an empty, uninitialized cgi object, loading environment variables into the member variables. This constructor is rarely used, and must be followed by a manual call to the Initialize() method.
| |
|
| |
| htmlISAPI( EXTENSION_CONTROL_BLOCK * xcb )
| |
| Constructs the object from the xcb ISAPI extension control block pointer. Implicitly executes the Initialize() method, passing along xcb as the argument.
| |
|
| |
| virtual ~htmlISAPI()
| |
| Destroys the object.
| |
|
| |
| GetEnv | virtual String GetEnv( const String& name )
| |
| Retrieves the value for name from the environment as a string. This method provides a uniform interface across multiple platforms for accessing data from the web server. The default implementation uses the C-lanugage getenv() function internally.
| |
|
| |
| Initialize | int Initialize( EXTENSION_CONTROL_BLOCK * xcb )
| |
| Initializes the object, decoding content (such as name/value pairs from a form) passed from the browser to the server through xcb. If successful, the number of name/value pairs received from the system is returned, zero if no data was received or if there was an error. This method is used in conjunction with the empty htmlISAPI() constructor.
| |
|
| |
| The following example illustrates use of the htmlISAPI class within an ISAPI server extension DLL. Note that, except for the DLL-related code, the html++ code for interacting with ISAPI is nearly identical that for using CGI.
| |
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| // Result code 200 informs the browser that the
| |
| // request was successful. Note that this is also
| |
| // defined by MFC in <afxisapi.h>
| |
| #ifndef HTTP_STATUS_OK
| |
| #define HTTP_STATUS_OK 200
| |
| #endif
| |
|
| |
| // Required entry points for the DLL interface.
| |
| extern "C" BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO * ver)
| |
| {
| |
| // Refer to <httpext.h> for a complete list of definitions.
| |
| ver->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR,
| |
| HSE_VERSION_MAJOR);
| |
| lstrcpyn( ver->lpszExtensionDesc,
| |
| "html++ ISAPI server extension",
| |
| HSE_MAX_EXT_DLL_NAME_LEN ) ;
| |
| return TRUE ;
| |
| }
| |
|
| |
| extern "C" DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK * xcb)
| |
| {
| |
| DWORD rval = HSE_STATUS_SUCCESS ; // or HSE_STATUS_ERROR
| |
| htmlISAPI server( xcb ) ;
| |
|
| |
| htmlPage page ;
| |
| // ... proceed with generating HTML output using
| |
| // normal html++ classes...
| |
|
| |
| // Output the page contents.
| |
| server << page ;
| |
|
| |
| // Set the status code sent back to the browser.
| |
| xcb->dwHttpStatusCode = HTTP_STATUS_OK ;
| |
| return rval ;
| |
| }
| |
|
| |
