Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
11 KiB

  1. /********
  2. *
  3. * Copyright (c) 1995 Process Software Corporation
  4. *
  5. * Copyright (c) 1995-1997 Microsoft Corporation
  6. *
  7. *
  8. * Module Name : HttpExt.h
  9. *
  10. * Abstract :
  11. *
  12. * This module contains the structure definitions and prototypes for the
  13. * HTTP Server Extension interface used to build ISAPI Applications
  14. *
  15. ******************/
  16. #ifndef _HTTPEXT_H_
  17. #define _HTTPEXT_H_
  18. #include <windows.h>
  19. #include <wincrypt.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /************************************************************
  24. * Manifest Constants
  25. ************************************************************/
  26. #define HSE_VERSION_MAJOR 4 // major version of this spec
  27. #define HSE_VERSION_MINOR 0 // minor version of this spec
  28. #define HSE_LOG_BUFFER_LEN 80
  29. #define HSE_MAX_EXT_DLL_NAME_LEN 256
  30. #define HSE_VERSION MAKELONG( HSE_VERSION_MINOR, HSE_VERSION_MAJOR )
  31. //
  32. // the following are the status codes returned by the Extension DLL
  33. //
  34. #define HSE_STATUS_SUCCESS 1
  35. #define HSE_STATUS_SUCCESS_AND_KEEP_CONN 2
  36. #define HSE_STATUS_PENDING 3
  37. #define HSE_STATUS_ERROR 4
  38. //
  39. // The following are the values to request services with the
  40. // ServerSupportFunction().
  41. // Values from 0 to 1000 are reserved for future versions of the interface
  42. #define HSE_REQ_BASE 0
  43. #define HSE_REQ_SEND_URL_REDIRECT_RESP ( HSE_REQ_BASE + 1 )
  44. #define HSE_REQ_SEND_URL ( HSE_REQ_BASE + 2 )
  45. #define HSE_REQ_SEND_RESPONSE_HEADER ( HSE_REQ_BASE + 3 )
  46. #define HSE_REQ_DONE_WITH_SESSION ( HSE_REQ_BASE + 4 )
  47. #define HSE_REQ_END_RESERVED 1000
  48. //
  49. // These are Microsoft specific extensions
  50. //
  51. #define HSE_REQ_MAP_URL_TO_PATH (HSE_REQ_END_RESERVED+1)
  52. #define HSE_REQ_GET_SSPI_INFO (HSE_REQ_END_RESERVED+2)
  53. #define HSE_APPEND_LOG_PARAMETER (HSE_REQ_END_RESERVED+3)
  54. #define HSE_REQ_SEND_URL_EX (HSE_REQ_END_RESERVED+4)
  55. #define HSE_REQ_IO_COMPLETION (HSE_REQ_END_RESERVED+5)
  56. #define HSE_REQ_TRANSMIT_FILE (HSE_REQ_END_RESERVED+6)
  57. #define HSE_REQ_REFRESH_ISAPI_ACL (HSE_REQ_END_RESERVED+7)
  58. #define HSE_REQ_IS_KEEP_CONN (HSE_REQ_END_RESERVED+8)
  59. #define HSE_REQ_ASYNC_READ_CLIENT (HSE_REQ_END_RESERVED+10)
  60. #define HSE_REQ_GET_IMPERSONATION_TOKEN (HSE_REQ_END_RESERVED+11)
  61. #define HSE_REQ_MAP_URL_TO_PATH_EX (HSE_REQ_END_RESERVED+12)
  62. #define HSE_REQ_ABORTIVE_CLOSE (HSE_REQ_END_RESERVED+14)
  63. #define HSE_REQ_GET_CERT_INFO_EX (HSE_REQ_END_RESERVED+15)
  64. #define HSE_REQ_SEND_RESPONSE_HEADER_EX (HSE_REQ_END_RESERVED+16)
  65. //
  66. // Bit Flags for TerminateExtension
  67. //
  68. // HSE_TERM_ADVISORY_UNLOAD - Server wants to unload the extension,
  69. // extension can return TRUE if OK, FALSE if the server should not
  70. // unload the extension
  71. //
  72. // HSE_TERM_MUST_UNLOAD - Server indicating the extension is about to be
  73. // unloaded, the extension cannot refuse.
  74. //
  75. #define HSE_TERM_ADVISORY_UNLOAD 0x00000001
  76. #define HSE_TERM_MUST_UNLOAD 0x00000002
  77. //
  78. // Flags for IO Functions, supported for IO Funcs.
  79. // TF means ServerSupportFunction( HSE_REQ_TRANSMIT_FILE)
  80. //
  81. # define HSE_IO_SYNC 0x00000001 // for WriteClient
  82. # define HSE_IO_ASYNC 0x00000002 // for WriteClient/TF
  83. # define HSE_IO_DISCONNECT_AFTER_SEND 0x00000004 // for TF
  84. # define HSE_IO_SEND_HEADERS 0x00000008 // for TF
  85. /************************************************************
  86. * Type Definitions
  87. ************************************************************/
  88. typedef LPVOID HCONN;
  89. //
  90. // structure passed to GetExtensionVersion()
  91. //
  92. typedef struct _HSE_VERSION_INFO {
  93. DWORD dwExtensionVersion;
  94. CHAR lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN];
  95. } HSE_VERSION_INFO, *LPHSE_VERSION_INFO;
  96. //
  97. // structure passed to extension procedure on a new request
  98. //
  99. typedef struct _EXTENSION_CONTROL_BLOCK {
  100. DWORD cbSize; // size of this struct.
  101. DWORD dwVersion; // version info of this spec
  102. HCONN ConnID; // Context number not to be modified!
  103. DWORD dwHttpStatusCode; // HTTP Status code
  104. CHAR lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info specific to this Extension DLL
  105. LPSTR lpszMethod; // REQUEST_METHOD
  106. LPSTR lpszQueryString; // QUERY_STRING
  107. LPSTR lpszPathInfo; // PATH_INFO
  108. LPSTR lpszPathTranslated; // PATH_TRANSLATED
  109. DWORD cbTotalBytes; // Total bytes indicated from client
  110. DWORD cbAvailable; // Available number of bytes
  111. LPBYTE lpbData; // pointer to cbAvailable bytes
  112. LPSTR lpszContentType; // Content type of client data
  113. BOOL (WINAPI * GetServerVariable) ( HCONN hConn,
  114. LPSTR lpszVariableName,
  115. LPVOID lpvBuffer,
  116. LPDWORD lpdwSize );
  117. BOOL (WINAPI * WriteClient) ( HCONN ConnID,
  118. LPVOID Buffer,
  119. LPDWORD lpdwBytes,
  120. DWORD dwReserved );
  121. BOOL (WINAPI * ReadClient) ( HCONN ConnID,
  122. LPVOID lpvBuffer,
  123. LPDWORD lpdwSize );
  124. BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
  125. DWORD dwHSERRequest,
  126. LPVOID lpvBuffer,
  127. LPDWORD lpdwSize,
  128. LPDWORD lpdwDataType );
  129. } EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;
  130. //
  131. // Bit field of flags that can be on a virtual directory
  132. //
  133. #define HSE_URL_FLAGS_READ 0x00000001 // Allow for Read
  134. #define HSE_URL_FLAGS_WRITE 0x00000002 // Allow for Write
  135. #define HSE_URL_FLAGS_EXECUTE 0x00000004 // Allow for Execute
  136. #define HSE_URL_FLAGS_SSL 0x00000008 // Require SSL
  137. #define HSE_URL_FLAGS_DONT_CACHE 0x00000010 // Don't cache (vroot only)
  138. #define HSE_URL_FLAGS_NEGO_CERT 0x00000020 // Allow client SSL certs
  139. #define HSE_URL_FLAGS_REQUIRE_CERT 0x00000040 // Require client SSL certs
  140. #define HSE_URL_FLAGS_MAP_CERT 0x00000080 // Map SSL cert to NT account
  141. #define HSE_URL_FLAGS_SSL128 0x00000100 // Require 128 bit SSL
  142. #define HSE_URL_FLAGS_SCRIPT 0x00000200 // Allow for Script execution
  143. #define HSE_URL_FLAGS_MASK 0x000003ff
  144. //
  145. // Structure for extended information on a URL mapping
  146. //
  147. typedef struct _HSE_URL_MAPEX_INFO {
  148. CHAR lpszPath[MAX_PATH]; // Physical path root mapped to
  149. DWORD dwFlags; // Flags associated with this URL path
  150. DWORD cchMatchingPath; // Number of matching characters in physical path
  151. DWORD cchMatchingURL; // Number of matching characters in URL
  152. DWORD dwReserved1;
  153. DWORD dwReserved2;
  154. } HSE_URL_MAPEX_INFO, * LPHSE_URL_MAPEX_INFO;
  155. //
  156. // PFN_HSE_IO_COMPLETION - callback function for the Async I/O Completion.
  157. //
  158. typedef VOID
  159. (WINAPI * PFN_HSE_IO_COMPLETION)(
  160. IN EXTENSION_CONTROL_BLOCK * pECB,
  161. IN PVOID pContext,
  162. IN DWORD cbIO,
  163. IN DWORD dwError
  164. );
  165. //
  166. // HSE_TF_INFO defines the type for HTTP SERVER EXTENSION support for
  167. // ISAPI applications to send files using TransmitFile.
  168. // A pointer to this object should be used with ServerSupportFunction()
  169. // for HSE_REQ_TRANSMIT_FILE.
  170. //
  171. typedef struct _HSE_TF_INFO {
  172. //
  173. // callback and context information
  174. // the callback function will be called when IO is completed.
  175. // the context specified will be used during such callback.
  176. //
  177. // These values (if non-NULL) will override the one set by calling
  178. // ServerSupportFunction() with HSE_REQ_IO_COMPLETION
  179. //
  180. PFN_HSE_IO_COMPLETION pfnHseIO;
  181. PVOID pContext;
  182. // file should have been opened with FILE_FLAG_SEQUENTIAL_SCAN
  183. HANDLE hFile;
  184. //
  185. // HTTP header and status code
  186. // These fields are used only if HSE_IO_SEND_HEADERS is present in dwFlags
  187. //
  188. LPCSTR pszStatusCode; // HTTP Status Code eg: "200 OK"
  189. DWORD BytesToWrite; // special value of "0" means write entire file.
  190. DWORD Offset; // offset value within the file to start from
  191. PVOID pHead; // Head buffer to be sent before file data
  192. DWORD HeadLength; // header length
  193. PVOID pTail; // Tail buffer to be sent after file data
  194. DWORD TailLength; // tail length
  195. DWORD dwFlags; // includes HSE_IO_DISCONNECT_AFTER_SEND, ...
  196. } HSE_TF_INFO, * LPHSE_TF_INFO;
  197. //
  198. // HSE_SEND_HEADER_EX_INFO allows an ISAPI application to send headers
  199. // and specify keep-alive behavior in the same call.
  200. //
  201. typedef struct _HSE_SEND_HEADER_EX_INFO {
  202. //
  203. // HTTP status code and header
  204. //
  205. LPCSTR pszStatus; // HTTP status code eg: "200 OK"
  206. LPCSTR pszHeader; // HTTP header
  207. DWORD cchStatus; // number of characters in status code
  208. DWORD cchHeader; // number of characters in header
  209. BOOL fKeepConn; // keep client connection alive?
  210. } HSE_SEND_HEADER_EX_INFO, * LPHSE_SEND_HEADER_EX_INFO;
  211. //
  212. // CERT_CONTEXT_EX is passed as an an argument to
  213. // ServerSupportFunction( HSE_REQ_GET_CERT_INFO_EX )
  214. //
  215. typedef struct _CERT_CONTEXT_EX {
  216. CERT_CONTEXT CertContext;
  217. DWORD cbAllocated;
  218. DWORD dwCertificateFlags;
  219. } CERT_CONTEXT_EX;
  220. /************************************************************
  221. * Function Prototypes
  222. * o for functions exported from the ISAPI Application DLL
  223. ************************************************************/
  224. BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO *pVer );
  225. DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK *pECB );
  226. BOOL WINAPI TerminateExtension( DWORD dwFlags );
  227. // the following type declarations is for use in the server side
  228. typedef BOOL
  229. (WINAPI * PFN_GETEXTENSIONVERSION)( HSE_VERSION_INFO *pVer );
  230. typedef DWORD
  231. (WINAPI * PFN_HTTPEXTENSIONPROC )( EXTENSION_CONTROL_BLOCK * pECB );
  232. typedef BOOL (WINAPI * PFN_TERMINATEEXTENSION )( DWORD dwFlags );
  233. #ifdef __cplusplus
  234. }
  235. #endif
  236. #endif // end definition _HTTPEXT_H_