Leaked source code of windows server 2003
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.

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