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.

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