isapi_application.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _ISAPI_APPLICATION_H_
00023 #define _ISAPI_APPLICATION_H_
00024
00025 #include <httpext.h>
00026
00027 #include <dcl/delegate.h>
00028 #include <dcl/http_header.h>
00029 #include <dcl/web_application.h>
00030
00031 namespace dbp {
00032
00034
00052 class isapi_application: public web_application_int {
00053 friend DWORD ::HttpExtensionProc(EXTENSION_CONTROL_BLOCK*);
00054 public:
00055 isapi_application(): isapi_req(NULL) { };
00056 virtual void on_handle_request(on_request_handler handler) {
00057 request_handler = handler;
00058 };
00059 virtual void on_exception(on_exception_handler handler) {
00060 exception_handler = handler;
00061 };
00062 protected:
00063 int handle_request();
00064 virtual http_request get_request();
00065 virtual void send_response(const http_response &response);
00066 private:
00067 LPEXTENSION_CONTROL_BLOCK isapi_req;
00068 on_request_handler request_handler;
00069 on_exception_handler exception_handler;
00070 std::string get_server_variable(const std::string &name) const;
00071 };
00072
00073 }
00074
00075 #undef IMPLEMENT_APP
00076 #define IMPLEMENT_APP(module_name, app_class) \
00077 extern "C" { \
00078 \
00079 __declspec(dllexport) \
00080 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO* pVer) { \
00081 pVer->dwExtensionVersion = \
00082 MAKELONG(HSE_VERSION_MINOR,HSE_VERSION_MAJOR); \
00083 strncpy(pVer->lpszExtensionDesc, #module_name, \
00084 HSE_MAX_EXT_DLL_NAME_LEN); \
00085 return true; \
00086 } \
00087 \
00088 __declspec(dllexport) \
00089 BOOL WINAPI TerminateExtension(DWORD dwFlags) { \
00090 return true; \
00091 } \
00092 \
00093 __declspec(dllexport) \
00094 DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) { \
00095 app_class app; \
00096 dbp::isapi_application &_app = app.application_impl(); \
00097 _app.isapi_req = lpECB; \
00098 return _app.handle_request(); \
00099 } \
00100 \
00101 } //extern
00102
00103 #endif