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.

335 lines
12 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_EXECUTE_CHILD (HSE_REQ_END_RESERVED+13)
  63. #define HSE_REQ_ABORTIVE_CLOSE (HSE_REQ_END_RESERVED+14)
  64. #define HSE_REQ_GET_CERT_INFO_EX (HSE_REQ_END_RESERVED+15)
  65. #define HSE_REQ_SEND_RESPONSE_HEADER_EX (HSE_REQ_END_RESERVED+16)
  66. //
  67. // Bit Flags for TerminateExtension
  68. //
  69. // HSE_TERM_ADVISORY_UNLOAD - Server wants to unload the extension,
  70. // extension can return TRUE if OK, FALSE if the server should not
  71. // unload the extension
  72. //
  73. // HSE_TERM_MUST_UNLOAD - Server indicating the extension is about to be
  74. // unloaded, the extension cannot refuse.
  75. //
  76. #define HSE_TERM_ADVISORY_UNLOAD 0x00000001
  77. #define HSE_TERM_MUST_UNLOAD 0x00000002
  78. //
  79. // Flags for IO Functions, supported for IO Funcs.
  80. // TF means ServerSupportFunction( HSE_REQ_TRANSMIT_FILE)
  81. //
  82. # define HSE_IO_SYNC 0x00000001 // for WriteClient
  83. # define HSE_IO_ASYNC 0x00000002 // for WriteClient/TF
  84. # define HSE_IO_DISCONNECT_AFTER_SEND 0x00000004 // for TF
  85. # define HSE_IO_SEND_HEADERS 0x00000008 // for TF
  86. //
  87. // Flags for HSE_REQ_EXECUTE_CHILD function
  88. //
  89. # define HSE_EXEC_NO_HEADERS 0x00000001 // Don't send any
  90. // headers of child
  91. # define HSE_EXEC_REDIRECT_ONLY 0x00000002 // Don't send any
  92. // headers of child
  93. // but send redirect
  94. // message
  95. # define HSE_EXEC_COMMAND 0x00000004 // Treat as shell
  96. // command instead of
  97. // URL
  98. /************************************************************
  99. * Type Definitions
  100. ************************************************************/
  101. typedef LPVOID HCONN;
  102. //
  103. // structure passed to GetExtensionVersion()
  104. //
  105. typedef struct _HSE_VERSION_INFO {
  106. DWORD dwExtensionVersion;
  107. CHAR lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN];
  108. } HSE_VERSION_INFO, *LPHSE_VERSION_INFO;
  109. //
  110. // structure passed to extension procedure on a new request
  111. //
  112. typedef struct _EXTENSION_CONTROL_BLOCK {
  113. DWORD cbSize; // size of this struct.
  114. DWORD dwVersion; // version info of this spec
  115. HCONN ConnID; // Context number not to be modified!
  116. DWORD dwHttpStatusCode; // HTTP Status code
  117. CHAR lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info specific to this Extension DLL
  118. LPSTR lpszMethod; // REQUEST_METHOD
  119. LPSTR lpszQueryString; // QUERY_STRING
  120. LPSTR lpszPathInfo; // PATH_INFO
  121. LPSTR lpszPathTranslated; // PATH_TRANSLATED
  122. DWORD cbTotalBytes; // Total bytes indicated from client
  123. DWORD cbAvailable; // Available number of bytes
  124. LPBYTE lpbData; // pointer to cbAvailable bytes
  125. LPSTR lpszContentType; // Content type of client data
  126. BOOL (WINAPI * GetServerVariable) ( HCONN hConn,
  127. LPSTR lpszVariableName,
  128. LPVOID lpvBuffer,
  129. LPDWORD lpdwSize );
  130. BOOL (WINAPI * WriteClient) ( HCONN ConnID,
  131. LPVOID Buffer,
  132. LPDWORD lpdwBytes,
  133. DWORD dwReserved );
  134. BOOL (WINAPI * ReadClient) ( HCONN ConnID,
  135. LPVOID lpvBuffer,
  136. LPDWORD lpdwSize );
  137. BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
  138. DWORD dwHSERRequest,
  139. LPVOID lpvBuffer,
  140. LPDWORD lpdwSize,
  141. LPDWORD lpdwDataType );
  142. } EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;
  143. //
  144. // Bit field of flags that can be on a virtual directory
  145. //
  146. #define HSE_URL_FLAGS_READ 0x00000001 // Allow for Read
  147. #define HSE_URL_FLAGS_WRITE 0x00000002 // Allow for Write
  148. #define HSE_URL_FLAGS_EXECUTE 0x00000004 // Allow for Execute
  149. #define HSE_URL_FLAGS_SSL 0x00000008 // Require SSL
  150. #define HSE_URL_FLAGS_DONT_CACHE 0x00000010 // Don't cache (vroot only)
  151. #define HSE_URL_FLAGS_NEGO_CERT 0x00000020 // Allow client SSL certs
  152. #define HSE_URL_FLAGS_REQUIRE_CERT 0x00000040 // Require client SSL certs
  153. #define HSE_URL_FLAGS_MAP_CERT 0x00000080 // Map SSL cert to NT account
  154. #define HSE_URL_FLAGS_SSL128 0x00000100 // Require 128 bit SSL
  155. #define HSE_URL_FLAGS_SCRIPT 0x00000200 // Allow for Script execution
  156. #define HSE_URL_FLAGS_MASK 0x000003ff
  157. //
  158. // Structure for extended information on a URL mapping
  159. //
  160. typedef struct _HSE_URL_MAPEX_INFO {
  161. CHAR lpszPath[MAX_PATH]; // Physical path root mapped to
  162. DWORD dwFlags; // Flags associated with this URL path
  163. DWORD cchMatchingPath; // Number of matching characters in physical path
  164. DWORD cchMatchingURL; // Number of matching characters in URL
  165. DWORD dwReserved1;
  166. DWORD dwReserved2;
  167. } HSE_URL_MAPEX_INFO, * LPHSE_URL_MAPEX_INFO;
  168. //
  169. // PFN_HSE_IO_COMPLETION - callback function for the Async I/O Completion.
  170. //
  171. typedef VOID
  172. (WINAPI * PFN_HSE_IO_COMPLETION)(
  173. IN EXTENSION_CONTROL_BLOCK * pECB,
  174. IN PVOID pContext,
  175. IN DWORD cbIO,
  176. IN DWORD dwError
  177. );
  178. //
  179. // HSE_TF_INFO defines the type for HTTP SERVER EXTENSION support for
  180. // ISAPI applications to send files using TransmitFile.
  181. // A pointer to this object should be used with ServerSupportFunction()
  182. // for HSE_REQ_TRANSMIT_FILE.
  183. //
  184. typedef struct _HSE_TF_INFO {
  185. //
  186. // callback and context information
  187. // the callback function will be called when IO is completed.
  188. // the context specified will be used during such callback.
  189. //
  190. // These values (if non-NULL) will override the one set by calling
  191. // ServerSupportFunction() with HSE_REQ_IO_COMPLETION
  192. //
  193. PFN_HSE_IO_COMPLETION pfnHseIO;
  194. PVOID pContext;
  195. // file should have been opened with FILE_FLAG_SEQUENTIAL_SCAN
  196. HANDLE hFile;
  197. //
  198. // HTTP header and status code
  199. // These fields are used only if HSE_IO_SEND_HEADERS is present in dwFlags
  200. //
  201. LPCSTR pszStatusCode; // HTTP Status Code eg: "200 OK"
  202. DWORD BytesToWrite; // special value of "0" means write entire file.
  203. DWORD Offset; // offset value within the file to start from
  204. PVOID pHead; // Head buffer to be sent before file data
  205. DWORD HeadLength; // header length
  206. PVOID pTail; // Tail buffer to be sent after file data
  207. DWORD TailLength; // tail length
  208. DWORD dwFlags; // includes HSE_IO_DISCONNECT_AFTER_SEND, ...
  209. } HSE_TF_INFO, * LPHSE_TF_INFO;
  210. //
  211. // HSE_SEND_HEADER_EX_INFO allows an ISAPI application to send headers
  212. // and specify keep-alive behavior in the same call.
  213. //
  214. typedef struct _HSE_SEND_HEADER_EX_INFO {
  215. //
  216. // HTTP status code and header
  217. //
  218. LPCSTR pszStatus; // HTTP status code eg: "200 OK"
  219. LPCSTR pszHeader; // HTTP header
  220. DWORD cchStatus; // number of characters in status code
  221. DWORD cchHeader; // number of characters in header
  222. BOOL fKeepConn; // keep client connection alive?
  223. } HSE_SEND_HEADER_EX_INFO, * LPHSE_SEND_HEADER_EX_INFO;
  224. //
  225. // CERT_CONTEXT_EX is passed as an an argument to
  226. // ServerSupportFunction( HSE_REQ_GET_CERT_INFO_EX )
  227. //
  228. typedef struct _CERT_CONTEXT_EX {
  229. CERT_CONTEXT CertContext;
  230. DWORD cbAllocated;
  231. DWORD dwCertificateFlags;
  232. } CERT_CONTEXT_EX;
  233. /************************************************************
  234. * Function Prototypes
  235. * o for functions exported from the ISAPI Application DLL
  236. ************************************************************/
  237. BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO *pVer );
  238. DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK *pECB );
  239. BOOL WINAPI TerminateExtension( DWORD dwFlags );
  240. // the following type declarations is for use in the server side
  241. typedef BOOL
  242. (WINAPI * PFN_GETEXTENSIONVERSION)( HSE_VERSION_INFO *pVer );
  243. typedef DWORD
  244. (WINAPI * PFN_HTTPEXTENSIONPROC )( EXTENSION_CONTROL_BLOCK * pECB );
  245. typedef BOOL (WINAPI * PFN_TERMINATEEXTENSION )( DWORD dwFlags );
  246. #ifdef __cplusplus
  247. }
  248. #endif
  249. #endif // end definition _HTTPEXT_H_