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.

466 lines
15 KiB

  1. /********
  2. *
  3. * Copyright (c) 1995 Process Software Corporation
  4. *
  5. * Copyright (c) 1995-1999 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. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /************************************************************
  23. * Manifest Constants
  24. ************************************************************/
  25. #define HSE_VERSION_MAJOR 6 // major version of this spec
  26. #define HSE_VERSION_MINOR 0 // minor version of this spec
  27. #define HSE_LOG_BUFFER_LEN 80
  28. #define HSE_MAX_EXT_DLL_NAME_LEN 256
  29. #define HSE_VERSION MAKELONG( HSE_VERSION_MINOR, HSE_VERSION_MAJOR )
  30. //
  31. // the following are the status codes returned by the Extension DLL
  32. //
  33. #define HSE_STATUS_SUCCESS 1
  34. #define HSE_STATUS_SUCCESS_AND_KEEP_CONN 2
  35. #define HSE_STATUS_PENDING 3
  36. #define HSE_STATUS_ERROR 4
  37. //
  38. // The following are the values to request services with the
  39. // ServerSupportFunction().
  40. // Values from 0 to 1000 are reserved for future versions of the interface
  41. #define HSE_REQ_BASE 0
  42. #define HSE_REQ_SEND_URL_REDIRECT_RESP ( HSE_REQ_BASE + 1 )
  43. #define HSE_REQ_SEND_URL ( HSE_REQ_BASE + 2 )
  44. #define HSE_REQ_SEND_RESPONSE_HEADER ( HSE_REQ_BASE + 3 )
  45. #define HSE_REQ_DONE_WITH_SESSION ( HSE_REQ_BASE + 4 )
  46. #define HSE_REQ_END_RESERVED 1000
  47. //
  48. // These are Microsoft specific extensions
  49. //
  50. #define HSE_REQ_MAP_URL_TO_PATH (HSE_REQ_END_RESERVED+1)
  51. #define HSE_REQ_GET_SSPI_INFO (HSE_REQ_END_RESERVED+2)
  52. #define HSE_APPEND_LOG_PARAMETER (HSE_REQ_END_RESERVED+3)
  53. #define HSE_REQ_IO_COMPLETION (HSE_REQ_END_RESERVED+5)
  54. #define HSE_REQ_TRANSMIT_FILE (HSE_REQ_END_RESERVED+6)
  55. #define HSE_REQ_REFRESH_ISAPI_ACL (HSE_REQ_END_RESERVED+7)
  56. #define HSE_REQ_IS_KEEP_CONN (HSE_REQ_END_RESERVED+8)
  57. #define HSE_REQ_ASYNC_READ_CLIENT (HSE_REQ_END_RESERVED+10)
  58. #define HSE_REQ_GET_IMPERSONATION_TOKEN (HSE_REQ_END_RESERVED+11)
  59. #define HSE_REQ_MAP_URL_TO_PATH_EX (HSE_REQ_END_RESERVED+12)
  60. #define HSE_REQ_ABORTIVE_CLOSE (HSE_REQ_END_RESERVED+14)
  61. #define HSE_REQ_GET_CERT_INFO_EX (HSE_REQ_END_RESERVED+15)
  62. #define HSE_REQ_SEND_RESPONSE_HEADER_EX (HSE_REQ_END_RESERVED+16)
  63. #define HSE_REQ_CLOSE_CONNECTION (HSE_REQ_END_RESERVED+17)
  64. #define HSE_REQ_IS_CONNECTED (HSE_REQ_END_RESERVED+18)
  65. #define HSE_REQ_EXTENSION_TRIGGER (HSE_REQ_END_RESERVED+20)
  66. #define HSE_REQ_VECTOR_SEND (HSE_REQ_END_RESERVED+22)
  67. #define HSE_REQ_MAP_UNICODE_URL_TO_PATH (HSE_REQ_END_RESERVED+23)
  68. #define HSE_REQ_MAP_UNICODE_URL_TO_PATH_EX (HSE_REQ_END_RESERVED+24)
  69. #define HSE_REQ_EXEC_URL (HSE_REQ_END_RESERVED+26)
  70. #define HSE_REQ_GET_EXEC_URL_STATUS (HSE_REQ_END_RESERVED+27)
  71. #define HSE_REQ_SEND_CUSTOM_ERROR (HSE_REQ_END_RESERVED+28)
  72. #define HSE_REQ_IS_IN_PROCESS (HSE_REQ_END_RESERVED+30)
  73. //
  74. // Bit Flags for TerminateExtension
  75. //
  76. // HSE_TERM_ADVISORY_UNLOAD - Server wants to unload the extension,
  77. // extension can return TRUE if OK, FALSE if the server should not
  78. // unload the extension
  79. //
  80. // HSE_TERM_MUST_UNLOAD - Server indicating the extension is about to be
  81. // unloaded, the extension cannot refuse.
  82. //
  83. #define HSE_TERM_ADVISORY_UNLOAD 0x00000001
  84. #define HSE_TERM_MUST_UNLOAD 0x00000002
  85. //
  86. // Flags for IO Functions, supported for IO Funcs.
  87. // TF means ServerSupportFunction( HSE_REQ_TRANSMIT_FILE)
  88. //
  89. # define HSE_IO_SYNC 0x00000001 // for WriteClient
  90. # define HSE_IO_ASYNC 0x00000002 // for WriteClient/TF/EU
  91. # define HSE_IO_DISCONNECT_AFTER_SEND 0x00000004 // for TF
  92. # define HSE_IO_SEND_HEADERS 0x00000008 // for TF
  93. # define HSE_IO_NODELAY 0x00001000 // turn off nagling
  94. /************************************************************
  95. * Type Definitions
  96. ************************************************************/
  97. typedef LPVOID HCONN;
  98. //
  99. // structure passed to GetExtensionVersion()
  100. //
  101. typedef struct _HSE_VERSION_INFO {
  102. DWORD dwExtensionVersion;
  103. CHAR lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN];
  104. } HSE_VERSION_INFO, *LPHSE_VERSION_INFO;
  105. //
  106. // structure passed to extension procedure on a new request
  107. //
  108. typedef struct _EXTENSION_CONTROL_BLOCK {
  109. DWORD cbSize; // size of this struct.
  110. DWORD dwVersion; // version info of this spec
  111. HCONN ConnID; // Context number not to be modified!
  112. DWORD dwHttpStatusCode; // HTTP Status code
  113. CHAR lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info specific to this Extension DLL
  114. LPSTR lpszMethod; // REQUEST_METHOD
  115. LPSTR lpszQueryString; // QUERY_STRING
  116. LPSTR lpszPathInfo; // PATH_INFO
  117. LPSTR lpszPathTranslated; // PATH_TRANSLATED
  118. DWORD cbTotalBytes; // Total bytes indicated from client
  119. DWORD cbAvailable; // Available number of bytes
  120. LPBYTE lpbData; // pointer to cbAvailable bytes
  121. LPSTR lpszContentType; // Content type of client data
  122. BOOL (WINAPI * GetServerVariable) ( HCONN hConn,
  123. LPSTR lpszVariableName,
  124. LPVOID lpvBuffer,
  125. LPDWORD lpdwSize );
  126. BOOL (WINAPI * WriteClient) ( HCONN ConnID,
  127. LPVOID Buffer,
  128. LPDWORD lpdwBytes,
  129. DWORD dwReserved );
  130. BOOL (WINAPI * ReadClient) ( HCONN ConnID,
  131. LPVOID lpvBuffer,
  132. LPDWORD lpdwSize );
  133. BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
  134. DWORD dwHSERequest,
  135. LPVOID lpvBuffer,
  136. LPDWORD lpdwSize,
  137. LPDWORD lpdwDataType );
  138. } EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;
  139. //
  140. // Bit field of flags that can be on a virtual directory
  141. //
  142. #define HSE_URL_FLAGS_READ 0x00000001 // Allow for Read
  143. #define HSE_URL_FLAGS_WRITE 0x00000002 // Allow for Write
  144. #define HSE_URL_FLAGS_EXECUTE 0x00000004 // Allow for Execute
  145. #define HSE_URL_FLAGS_SSL 0x00000008 // Require SSL
  146. #define HSE_URL_FLAGS_DONT_CACHE 0x00000010 // Don't cache (vroot only)
  147. #define HSE_URL_FLAGS_NEGO_CERT 0x00000020 // Allow client SSL certs
  148. #define HSE_URL_FLAGS_REQUIRE_CERT 0x00000040 // Require client SSL certs
  149. #define HSE_URL_FLAGS_MAP_CERT 0x00000080 // Map SSL cert to NT account
  150. #define HSE_URL_FLAGS_SSL128 0x00000100 // Require 128 bit SSL
  151. #define HSE_URL_FLAGS_SCRIPT 0x00000200 // Allow for Script execution
  152. #define HSE_URL_FLAGS_MASK 0x000003ff
  153. //
  154. // Structure for extended information on a URL mapping
  155. //
  156. typedef struct _HSE_URL_MAPEX_INFO {
  157. CHAR lpszPath[MAX_PATH]; // Physical path root mapped to
  158. DWORD dwFlags; // Flags associated with this URL path
  159. DWORD cchMatchingPath; // Number of matching characters in physical path
  160. DWORD cchMatchingURL; // Number of matching characters in URL
  161. DWORD dwReserved1;
  162. DWORD dwReserved2;
  163. } HSE_URL_MAPEX_INFO, * LPHSE_URL_MAPEX_INFO;
  164. typedef struct _HSE_UNICODE_URL_MAPEX_INFO {
  165. WCHAR lpszPath[MAX_PATH]; // Physical path root mapped to
  166. DWORD dwFlags; // Flags associated with this URL path
  167. DWORD cchMatchingPath; // Number of matching characters in physical path
  168. DWORD cchMatchingURL; // Number of matching characters in URL
  169. } HSE_UNICODE_URL_MAPEX_INFO, * LPHSE_UNICODE_URL_MAPEX_INFO;
  170. //
  171. // PFN_HSE_IO_COMPLETION - callback function for the Async I/O Completion.
  172. //
  173. typedef VOID
  174. (WINAPI * PFN_HSE_IO_COMPLETION)(
  175. IN EXTENSION_CONTROL_BLOCK * pECB,
  176. IN PVOID pContext,
  177. IN DWORD cbIO,
  178. IN DWORD dwError
  179. );
  180. //
  181. // HSE_TF_INFO defines the type for HTTP SERVER EXTENSION support for
  182. // ISAPI applications to send files using TransmitFile.
  183. // A pointer to this object should be used with ServerSupportFunction()
  184. // for HSE_REQ_TRANSMIT_FILE.
  185. //
  186. typedef struct _HSE_TF_INFO {
  187. //
  188. // callback and context information
  189. // the callback function will be called when IO is completed.
  190. // the context specified will be used during such callback.
  191. //
  192. // These values (if non-NULL) will override the one set by calling
  193. // ServerSupportFunction() with HSE_REQ_IO_COMPLETION
  194. //
  195. PFN_HSE_IO_COMPLETION pfnHseIO;
  196. PVOID pContext;
  197. // file should have been opened with FILE_FLAG_SEQUENTIAL_SCAN
  198. HANDLE hFile;
  199. //
  200. // HTTP header and status code
  201. // These fields are used only if HSE_IO_SEND_HEADERS is present in dwFlags
  202. //
  203. LPCSTR pszStatusCode; // HTTP Status Code eg: "200 OK"
  204. DWORD BytesToWrite; // special value of "0" means write entire file.
  205. DWORD Offset; // offset value within the file to start from
  206. PVOID pHead; // Head buffer to be sent before file data
  207. DWORD HeadLength; // header length
  208. PVOID pTail; // Tail buffer to be sent after file data
  209. DWORD TailLength; // tail length
  210. DWORD dwFlags; // includes HSE_IO_DISCONNECT_AFTER_SEND, ...
  211. } HSE_TF_INFO, * LPHSE_TF_INFO;
  212. //
  213. // HSE_SEND_HEADER_EX_INFO allows an ISAPI application to send headers
  214. // and specify keep-alive behavior in the same call.
  215. //
  216. typedef struct _HSE_SEND_HEADER_EX_INFO {
  217. //
  218. // HTTP status code and header
  219. //
  220. LPCSTR pszStatus; // HTTP status code eg: "200 OK"
  221. LPCSTR pszHeader; // HTTP header
  222. DWORD cchStatus; // number of characters in status code
  223. DWORD cchHeader; // number of characters in header
  224. BOOL fKeepConn; // keep client connection alive?
  225. } HSE_SEND_HEADER_EX_INFO, * LPHSE_SEND_HEADER_EX_INFO;
  226. //
  227. // Flags for use with HSE_REQ_EXEC_URL
  228. //
  229. #define HSE_EXEC_URL_SYNC 0x01
  230. #define HSE_EXEC_URL_NO_HEADERS 0x02
  231. #define HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR 0x04
  232. #define HSE_EXEC_URL_IGNORE_APPPOOL 0x08
  233. #define HSE_EXEC_URL_IGNORE_VALIDATION_AND_RANGE 0x10
  234. #define HSE_EXEC_URL_DISABLE_CUSTOM_ERROR 0x20
  235. #define HSE_EXEC_URL_SSI_CMD 0x40
  236. #define HSE_EXEC_URL_ASYNC 0x80
  237. //
  238. // HSE_EXEC_URL_USER_INFO provides a new user content for use with
  239. // HSE_REQ_EXEC_URL
  240. //
  241. typedef struct _HSE_EXEC_URL_USER_INFO {
  242. HANDLE hImpersonationToken;
  243. LPSTR pszCustomUserName;
  244. LPSTR pszCustomAuthType;
  245. } HSE_EXEC_URL_USER_INFO, * LPHSE_EXEC_URL_USER_INFO;
  246. //
  247. // HSE_EXEC_URL_ENTITY_INFO describes the entity body to be provided
  248. // to the executed request using HSE_REQ_EXEC_URL
  249. //
  250. typedef struct _HSE_EXEC_URL_ENTITY_INFO {
  251. DWORD cbAvailable;
  252. LPVOID lpbData;
  253. } HSE_EXEC_URL_ENTITY_INFO, * LPHSE_EXEC_URL_ENTITY_INFO;
  254. //
  255. // HSE_EXEC_URL_STATUS provides the status of the last HSE_REQ_EXEC_URL
  256. // call
  257. //
  258. typedef struct _HSE_EXEC_URL_STATUS {
  259. USHORT uHttpStatusCode;
  260. USHORT uHttpSubStatus;
  261. DWORD dwWin32Error;
  262. } HSE_EXEC_URL_STATUS, * LPHSE_EXEC_URL_STATUS;
  263. //
  264. // HSE_EXEC_URL_INFO provides a description of the request to execute
  265. // on behalf of the ISAPI.
  266. //
  267. typedef struct _HSE_EXEC_URL_INFO {
  268. LPSTR pszUrl; // URL to execute
  269. LPSTR pszMethod; // Method
  270. LPSTR pszChildHeaders; // Request headers for child
  271. LPHSE_EXEC_URL_USER_INFO pUserInfo; // User for new request
  272. LPHSE_EXEC_URL_ENTITY_INFO pEntity; // Entity body for new request
  273. DWORD dwExecUrlFlags; // Flags
  274. } HSE_EXEC_URL_INFO, * LPHSE_EXEC_URL_INFO;
  275. //
  276. // HSE_CUSTOM_ERROR_INFO structured used in HSE_REQ_SEND_CUSTOM_ERROR
  277. //
  278. typedef struct _HSE_CUSTOM_ERROR_INFO {
  279. CHAR * pszStatus;
  280. USHORT uHttpSubError;
  281. BOOL fAsync;
  282. } HSE_CUSTOM_ERROR_INFO, * LPHSE_CUSTOM_ERROR_INFO;
  283. //
  284. // structures for the HSE_REQ_VECTOR_SEND ServerSupportFunction
  285. //
  286. //
  287. // element of the vector
  288. //
  289. typedef struct _HSE_VECTOR_ELEMENT
  290. {
  291. PVOID pBuffer; // The buffer to be sent
  292. HANDLE hFile; // The handle to read the data from
  293. // Note: both pBuffer and hFile should not be non-null
  294. ULONGLONG cbOffset; // Offset from the start of hFile
  295. ULONGLONG cbSize; // Number of bytes to send
  296. } HSE_VECTOR_ELEMENT, *LPHSE_VECTOR_ELEMENT;
  297. //
  298. // The whole vector to be passed to the ServerSupportFunction
  299. //
  300. typedef struct _HSE_RESPONSE_VECTOR
  301. {
  302. DWORD dwFlags; // combination of HSE_IO_* flags
  303. LPSTR pszStatus; // Status line to send like "200 OK"
  304. LPSTR pszHeaders; // Headers to send
  305. DWORD nElementCount; // Number of HSE_VECTOR_ELEMENT's
  306. LPHSE_VECTOR_ELEMENT lpElementArray; // Pointer to those elements
  307. } HSE_RESPONSE_VECTOR, *LPHSE_RESPONSE_VECTOR;
  308. #if(_WIN32_WINNT >= 0x400)
  309. #include <wincrypt.h>
  310. //
  311. // CERT_CONTEXT_EX is passed as an an argument to
  312. // ServerSupportFunction( HSE_REQ_GET_CERT_INFO_EX )
  313. //
  314. typedef struct _CERT_CONTEXT_EX {
  315. CERT_CONTEXT CertContext;
  316. DWORD cbAllocated;
  317. DWORD dwCertificateFlags;
  318. } CERT_CONTEXT_EX;
  319. #endif
  320. //
  321. // Flags for determining application type
  322. //
  323. #define HSE_APP_FLAG_IN_PROCESS 0
  324. #define HSE_APP_FLAG_ISOLATED_OOP 1
  325. #define HSE_APP_FLAG_POOLED_OOP 2
  326. /************************************************************
  327. * Function Prototypes
  328. * o for functions exported from the ISAPI Application DLL
  329. ************************************************************/
  330. BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO *pVer );
  331. DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK *pECB );
  332. BOOL WINAPI TerminateExtension( DWORD dwFlags );
  333. // the following type declarations is for use in the server side
  334. typedef BOOL
  335. (WINAPI * PFN_GETEXTENSIONVERSION)( HSE_VERSION_INFO *pVer );
  336. typedef DWORD
  337. (WINAPI * PFN_HTTPEXTENSIONPROC )( EXTENSION_CONTROL_BLOCK * pECB );
  338. typedef BOOL (WINAPI * PFN_TERMINATEEXTENSION )( DWORD dwFlags );
  339. #ifdef __cplusplus
  340. }
  341. #endif
  342. #endif // end definition _HTTPEXT_H_