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.

1229 lines
33 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. Http.h
  5. Abstract:
  6. This header corresponds to the HTTP API specification
  7. Revision History:
  8. --*/
  9. #ifndef __HTTP_H__
  10. #define __HTTP_H__
  11. #include <winsock2.h>
  12. #include <ws2tcpip.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif // __cplusplus
  16. //
  17. // Flags for HttpInitialize() and HttpTerminate()
  18. //
  19. //
  20. // HTTP_INITIALIZE_SERVER - Initializes the HTTP API layer and driver for
  21. // server applications.
  22. //
  23. // HTTP_INITIALIZE_CONFIG - Initializes the HTTP API layer and driver for
  24. // applications that will modify the HTTP
  25. // configuration.
  26. //
  27. // Notes -
  28. //
  29. // 1. These flags can be used in combination.
  30. //
  31. // 2. HttpTerminate() must be called for each call to HttpInitialize() made
  32. // with each flag set when invoking HttpInitialize. For example, one
  33. // could make two calls to HttpInitialize() setting HTTP_INITIALIZE_SERVER
  34. // the first time and HTTP_INITIALIZE_CONFIG the second time. One call
  35. // to HttpTerminate() with both flags set suffices to clean up both
  36. // calls to HttpInitialize().
  37. //
  38. #define HTTP_INITIALIZE_SERVER 0x00000001
  39. #define HTTP_INITIALIZE_CONFIG 0x00000002
  40. //
  41. // Flags for HttpReceiveHttpRequest().
  42. //
  43. // HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY - Specifies that the caller would like
  44. // any available entity body to be copied along with the protocol headers.
  45. //
  46. #define HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY 0x00000001
  47. //
  48. // Flags for HttpSendHttpResponse() and HttpSendResponseEntityBody().
  49. //
  50. // HTTP_SEND_RESPONSE_FLAG_DISCONNECT - Specifies that the network connection
  51. // should be disconnected immediately after sending the response, overriding
  52. // the HTTP protocol's persistent connection features, such as
  53. // "Connection: keep-alive".
  54. //
  55. // HTTP_SEND_RESPONSE_FLAG_MORE_DATA - Specifies that additional entity body
  56. // data will be sent by the caller.
  57. //
  58. #define HTTP_SEND_RESPONSE_FLAG_DISCONNECT 0x00000001
  59. #define HTTP_SEND_RESPONSE_FLAG_MORE_DATA 0x00000002
  60. //
  61. // Flags for HttpFlushResponseCache().
  62. //
  63. // HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE - Flushes the specified URL and all
  64. // hierarchally-related sub-URLs from the response or fragment cache.
  65. //
  66. #define HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE 0x00000001
  67. //
  68. // Opaque identifiers for various kernel objects.
  69. //
  70. typedef ULONGLONG HTTP_OPAQUE_ID, *PHTTP_OPAQUE_ID;
  71. typedef HTTP_OPAQUE_ID HTTP_REQUEST_ID, *PHTTP_REQUEST_ID;
  72. typedef HTTP_OPAQUE_ID HTTP_CONNECTION_ID, *PHTTP_CONNECTION_ID;
  73. typedef HTTP_OPAQUE_ID HTTP_RAW_CONNECTION_ID, *PHTTP_RAW_CONNECTION_ID;
  74. #define HTTP_NULL_ID (0ui64)
  75. #define HTTP_IS_NULL_ID(pid) (HTTP_NULL_ID == *(pid))
  76. #define HTTP_SET_NULL_ID(pid) (*(pid) = HTTP_NULL_ID)
  77. //
  78. // This structure defines a file byte range.
  79. //
  80. // If the Length field is HTTP_BYTE_RANGE_TO_EOF then the remainder of the
  81. // file (everything after StartingOffset) is sent.
  82. //
  83. #define HTTP_BYTE_RANGE_TO_EOF ((ULONGLONG)-1)
  84. typedef struct _HTTP_BYTE_RANGE
  85. {
  86. ULARGE_INTEGER StartingOffset;
  87. ULARGE_INTEGER Length;
  88. } HTTP_BYTE_RANGE, *PHTTP_BYTE_RANGE;
  89. //
  90. // The type for HTTP protocol version numbers.
  91. //
  92. typedef struct _HTTP_VERSION
  93. {
  94. USHORT MajorVersion;
  95. USHORT MinorVersion;
  96. } HTTP_VERSION, *PHTTP_VERSION;
  97. //
  98. // Some useful macros for HTTP protocol version manipulation.
  99. //
  100. #define HTTP_VERSION_UNKNOWN { 0, 0 }
  101. #define HTTP_VERSION_0_9 { 0, 9 }
  102. #define HTTP_VERSION_1_0 { 1, 0 }
  103. #define HTTP_VERSION_1_1 { 1, 1 }
  104. #define HTTP_SET_VERSION(version, major, minor) \
  105. do { \
  106. (version).MajorVersion = (major); \
  107. (version).MinorVersion = (minor); \
  108. } while (0, 0)
  109. #define HTTP_EQUAL_VERSION(version, major, minor) \
  110. ((version).MajorVersion == (major) && \
  111. (version).MinorVersion == (minor))
  112. #define HTTP_GREATER_VERSION(version, major, minor) \
  113. ((version).MajorVersion > (major) || \
  114. ((version).MajorVersion == (major) && \
  115. (version).MinorVersion > (minor)))
  116. #define HTTP_LESS_VERSION(version, major, minor) \
  117. ((version).MajorVersion < (major) || \
  118. ((version).MajorVersion == (major) && \
  119. (version).MinorVersion < (minor)))
  120. #define HTTP_NOT_EQUAL_VERSION(version, major, minor) \
  121. (!HTTP_EQUAL_VERSION(version, major, minor))
  122. #define HTTP_GREATER_EQUAL_VERSION(version, major, minor) \
  123. (!HTTP_LESS_VERSION(version, major, minor))
  124. #define HTTP_LESS_EQUAL_VERSION(version, major, minor) \
  125. (!HTTP_GREATER_VERSION(version, major, minor))
  126. //
  127. // The enum type for HTTP verbs.
  128. //
  129. typedef enum _HTTP_VERB
  130. {
  131. HttpVerbUnparsed,
  132. HttpVerbUnknown,
  133. HttpVerbInvalid,
  134. HttpVerbOPTIONS,
  135. HttpVerbGET,
  136. HttpVerbHEAD,
  137. HttpVerbPOST,
  138. HttpVerbPUT,
  139. HttpVerbDELETE,
  140. HttpVerbTRACE,
  141. HttpVerbCONNECT,
  142. HttpVerbTRACK, // used by Microsoft Cluster Server for a non-logged trace
  143. HttpVerbMOVE,
  144. HttpVerbCOPY,
  145. HttpVerbPROPFIND,
  146. HttpVerbPROPPATCH,
  147. HttpVerbMKCOL,
  148. HttpVerbLOCK,
  149. HttpVerbUNLOCK,
  150. HttpVerbSEARCH,
  151. HttpVerbMaximum
  152. } HTTP_VERB, *PHTTP_VERB;
  153. //
  154. // Symbols for all HTTP/1.1 headers and other tokens. Notice request +
  155. // response values overlap. Make sure you know which type of header array
  156. // you are indexing.
  157. //
  158. // These values are used as offsets into arrays and as token values in
  159. // HTTP_KNOWN_HEADER arrays in HTTP_REQUEST_HEADERS and HTTP_RESPONSE_HEADERS.
  160. //
  161. // See RFC 2616, HTTP/1.1, for further explanation of most of these headers.
  162. //
  163. typedef enum _HTTP_HEADER_ID
  164. {
  165. HttpHeaderCacheControl = 0, // general-header [section 4.5]
  166. HttpHeaderConnection = 1, // general-header [section 4.5]
  167. HttpHeaderDate = 2, // general-header [section 4.5]
  168. HttpHeaderKeepAlive = 3, // general-header [not in rfc]
  169. HttpHeaderPragma = 4, // general-header [section 4.5]
  170. HttpHeaderTrailer = 5, // general-header [section 4.5]
  171. HttpHeaderTransferEncoding = 6, // general-header [section 4.5]
  172. HttpHeaderUpgrade = 7, // general-header [section 4.5]
  173. HttpHeaderVia = 8, // general-header [section 4.5]
  174. HttpHeaderWarning = 9, // general-header [section 4.5]
  175. HttpHeaderAllow = 10, // entity-header [section 7.1]
  176. HttpHeaderContentLength = 11, // entity-header [section 7.1]
  177. HttpHeaderContentType = 12, // entity-header [section 7.1]
  178. HttpHeaderContentEncoding = 13, // entity-header [section 7.1]
  179. HttpHeaderContentLanguage = 14, // entity-header [section 7.1]
  180. HttpHeaderContentLocation = 15, // entity-header [section 7.1]
  181. HttpHeaderContentMd5 = 16, // entity-header [section 7.1]
  182. HttpHeaderContentRange = 17, // entity-header [section 7.1]
  183. HttpHeaderExpires = 18, // entity-header [section 7.1]
  184. HttpHeaderLastModified = 19, // entity-header [section 7.1]
  185. // Request Headers
  186. HttpHeaderAccept = 20, // request-header [section 5.3]
  187. HttpHeaderAcceptCharset = 21, // request-header [section 5.3]
  188. HttpHeaderAcceptEncoding = 22, // request-header [section 5.3]
  189. HttpHeaderAcceptLanguage = 23, // request-header [section 5.3]
  190. HttpHeaderAuthorization = 24, // request-header [section 5.3]
  191. HttpHeaderCookie = 25, // request-header [not in rfc]
  192. HttpHeaderExpect = 26, // request-header [section 5.3]
  193. HttpHeaderFrom = 27, // request-header [section 5.3]
  194. HttpHeaderHost = 28, // request-header [section 5.3]
  195. HttpHeaderIfMatch = 29, // request-header [section 5.3]
  196. HttpHeaderIfModifiedSince = 30, // request-header [section 5.3]
  197. HttpHeaderIfNoneMatch = 31, // request-header [section 5.3]
  198. HttpHeaderIfRange = 32, // request-header [section 5.3]
  199. HttpHeaderIfUnmodifiedSince = 33, // request-header [section 5.3]
  200. HttpHeaderMaxForwards = 34, // request-header [section 5.3]
  201. HttpHeaderProxyAuthorization = 35, // request-header [section 5.3]
  202. HttpHeaderReferer = 36, // request-header [section 5.3]
  203. HttpHeaderRange = 37, // request-header [section 5.3]
  204. HttpHeaderTe = 38, // request-header [section 5.3]
  205. HttpHeaderTranslate = 39, // request-header [webDAV, not in rfc 2518]
  206. HttpHeaderUserAgent = 40, // request-header [section 5.3]
  207. HttpHeaderRequestMaximum = 41,
  208. // Response Headers
  209. HttpHeaderAcceptRanges = 20, // response-header [section 6.2]
  210. HttpHeaderAge = 21, // response-header [section 6.2]
  211. HttpHeaderEtag = 22, // response-header [section 6.2]
  212. HttpHeaderLocation = 23, // response-header [section 6.2]
  213. HttpHeaderProxyAuthenticate = 24, // response-header [section 6.2]
  214. HttpHeaderRetryAfter = 25, // response-header [section 6.2]
  215. HttpHeaderServer = 26, // response-header [section 6.2]
  216. HttpHeaderSetCookie = 27, // response-header [not in rfc]
  217. HttpHeaderVary = 28, // response-header [section 6.2]
  218. HttpHeaderWwwAuthenticate = 29, // response-header [section 6.2]
  219. HttpHeaderResponseMaximum = 30,
  220. HttpHeaderMaximum = 41
  221. } HTTP_HEADER_ID, *PHTTP_HEADER_ID;
  222. //
  223. // Structure defining format of a known HTTP header.
  224. // Name is from HTTP_HEADER_ID.
  225. //
  226. typedef struct _HTTP_KNOWN_HEADER
  227. {
  228. USHORT RawValueLength; // in bytes not including the NUL
  229. PCSTR pRawValue;
  230. } HTTP_KNOWN_HEADER, *PHTTP_KNOWN_HEADER;
  231. //
  232. // Structure defining format of an unknown header.
  233. //
  234. typedef struct _HTTP_UNKNOWN_HEADER
  235. {
  236. USHORT NameLength; // in bytes not including the NUL
  237. USHORT RawValueLength; // in bytes not including the NUL
  238. PCSTR pName; // The header name (minus the ':' character)
  239. PCSTR pRawValue; // The header value
  240. } HTTP_UNKNOWN_HEADER, *PHTTP_UNKNOWN_HEADER;
  241. //
  242. // This enum defines a data source for a particular chunk of data.
  243. //
  244. typedef enum _HTTP_DATA_CHUNK_TYPE
  245. {
  246. HttpDataChunkFromMemory,
  247. HttpDataChunkFromFileHandle,
  248. HttpDataChunkFromFragmentCache,
  249. HttpDataChunkMaximum
  250. } HTTP_DATA_CHUNK_TYPE, *PHTTP_DATA_CHUNK_TYPE;
  251. //
  252. // This structure describes an individual data chunk.
  253. //
  254. typedef struct _HTTP_DATA_CHUNK
  255. {
  256. //
  257. // The type of this data chunk.
  258. //
  259. HTTP_DATA_CHUNK_TYPE DataChunkType;
  260. //
  261. // The data chunk structures, one per supported data chunk type.
  262. //
  263. union
  264. {
  265. //
  266. // From-memory data chunk.
  267. //
  268. struct
  269. {
  270. PVOID pBuffer;
  271. ULONG BufferLength;
  272. } FromMemory;
  273. //
  274. // From-file handle data chunk.
  275. //
  276. struct
  277. {
  278. HTTP_BYTE_RANGE ByteRange;
  279. HANDLE FileHandle;
  280. } FromFileHandle;
  281. //
  282. // From-fragment cache data chunk.
  283. //
  284. struct
  285. {
  286. USHORT FragmentNameLength; // in bytes not including the NUL
  287. PCWSTR pFragmentName;
  288. } FromFragmentCache;
  289. };
  290. } HTTP_DATA_CHUNK, *PHTTP_DATA_CHUNK;
  291. //
  292. // Structure defining format of request headers.
  293. //
  294. typedef struct _HTTP_REQUEST_HEADERS
  295. {
  296. //
  297. // The array of unknown HTTP headers and the number of
  298. // entries in the array.
  299. //
  300. USHORT UnknownHeaderCount;
  301. PHTTP_UNKNOWN_HEADER pUnknownHeaders;
  302. //
  303. // Trailers - we don't use these currently, reserved for a future release
  304. //
  305. USHORT TrailerCount; // Reserved, must be 0
  306. PHTTP_UNKNOWN_HEADER pTrailers; // Reserved, must be NULL
  307. //
  308. // Known headers.
  309. //
  310. HTTP_KNOWN_HEADER KnownHeaders[HttpHeaderRequestMaximum];
  311. } HTTP_REQUEST_HEADERS, *PHTTP_REQUEST_HEADERS;
  312. //
  313. // Structure defining format of response headers.
  314. //
  315. typedef struct _HTTP_RESPONSE_HEADERS
  316. {
  317. //
  318. // The array of unknown HTTP headers and the number of
  319. // entries in the array.
  320. //
  321. USHORT UnknownHeaderCount;
  322. PHTTP_UNKNOWN_HEADER pUnknownHeaders;
  323. //
  324. // Trailers - we don't use these currently, reserved for a future release
  325. //
  326. USHORT TrailerCount; // Reserved, must be 0
  327. PHTTP_UNKNOWN_HEADER pTrailers; // Reserved, must be NULL
  328. //
  329. // Known headers.
  330. //
  331. HTTP_KNOWN_HEADER KnownHeaders[HttpHeaderResponseMaximum];
  332. } HTTP_RESPONSE_HEADERS, *PHTTP_RESPONSE_HEADERS;
  333. //
  334. // Structure defining format of transport address. Use pLocalAddress->sa_family
  335. // to determine whether this is an IPv4 address (AF_INET) or IPv6 (AF_INET6).
  336. //
  337. // pRemoteAddress->sa_family will be the same as pLocalAddress->sa_family.
  338. //
  339. // SOCKADDRs are always in network order, not host order.
  340. //
  341. typedef struct _HTTP_TRANSPORT_ADDRESS
  342. {
  343. PSOCKADDR pRemoteAddress;
  344. PSOCKADDR pLocalAddress;
  345. } HTTP_TRANSPORT_ADDRESS, *PHTTP_TRANSPORT_ADDRESS;
  346. //
  347. // Structure defining format of cooked URL.
  348. //
  349. typedef struct _HTTP_COOKED_URL
  350. {
  351. //
  352. // Pointers overlap and point into pFullUrl. NULL if not present.
  353. //
  354. USHORT FullUrlLength; // in bytes not including the NUL
  355. USHORT HostLength; // in bytes (no NUL)
  356. USHORT AbsPathLength; // in bytes (no NUL)
  357. USHORT QueryStringLength; // in bytes (no NUL)
  358. PCWSTR pFullUrl; // points to "http://hostname:port/abs/.../path?query"
  359. PCWSTR pHost; // points to the first char in the hostname
  360. PCWSTR pAbsPath; // Points to the 3rd '/' char
  361. PCWSTR pQueryString; // Points to the 1st '?' char or NULL
  362. } HTTP_COOKED_URL, *PHTTP_COOKED_URL;
  363. //
  364. // An opaque context for URLs
  365. //
  366. typedef ULONGLONG HTTP_URL_CONTEXT;
  367. //
  368. // SSL Client certificate information.
  369. //
  370. typedef struct _HTTP_SSL_CLIENT_CERT_INFO
  371. {
  372. ULONG CertFlags;
  373. ULONG CertEncodedSize;
  374. PUCHAR pCertEncoded;
  375. HANDLE Token;
  376. BOOLEAN CertDeniedByMapper;
  377. } HTTP_SSL_CLIENT_CERT_INFO, *PHTTP_SSL_CLIENT_CERT_INFO;
  378. //
  379. // Data computed during SSL handshake.
  380. //
  381. typedef struct _HTTP_SSL_INFO
  382. {
  383. USHORT ServerCertKeySize;
  384. USHORT ConnectionKeySize;
  385. ULONG ServerCertIssuerSize;
  386. ULONG ServerCertSubjectSize;
  387. PCSTR pServerCertIssuer;
  388. PCSTR pServerCertSubject;
  389. PHTTP_SSL_CLIENT_CERT_INFO pClientCertInfo;
  390. ULONG SslClientCertNegotiated;
  391. } HTTP_SSL_INFO, *PHTTP_SSL_INFO;
  392. //
  393. // The structure of an HTTP request.
  394. //
  395. typedef struct _HTTP_REQUEST
  396. {
  397. //
  398. // Request flags (see HTTP_REQUEST_FLAG_* definitions below).
  399. //
  400. ULONG Flags;
  401. //
  402. // An opaque request identifier. These values are used by the driver
  403. // to correlate outgoing responses with incoming requests.
  404. //
  405. HTTP_CONNECTION_ID ConnectionId;
  406. HTTP_REQUEST_ID RequestId;
  407. //
  408. // The context associated with the URL prefix.
  409. //
  410. HTTP_URL_CONTEXT UrlContext;
  411. //
  412. // The HTTP version number.
  413. //
  414. HTTP_VERSION Version;
  415. //
  416. // The request verb.
  417. //
  418. HTTP_VERB Verb;
  419. //
  420. // The length of the verb string if the Verb field is HttpVerbUnknown.
  421. //
  422. USHORT UnknownVerbLength; // in bytes not including the NUL
  423. //
  424. // The length of the raw (uncooked) URL
  425. //
  426. USHORT RawUrlLength; // in bytes not including the NUL
  427. //
  428. // Pointer to the verb string if the Verb field is HttpVerbUnknown.
  429. //
  430. PCSTR pUnknownVerb;
  431. //
  432. // Pointer to the raw (uncooked) URL
  433. //
  434. PCSTR pRawUrl;
  435. //
  436. // The canonicalized Unicode URL
  437. //
  438. HTTP_COOKED_URL CookedUrl;
  439. //
  440. // Local and remote transport addresses for the connection.
  441. //
  442. HTTP_TRANSPORT_ADDRESS Address;
  443. //
  444. // The request headers.
  445. //
  446. HTTP_REQUEST_HEADERS Headers;
  447. //
  448. // The total number of bytes received from network for this request.
  449. //
  450. ULONGLONG BytesReceived;
  451. //
  452. // pEntityChunks is an array of EntityChunkCount HTTP_DATA_CHUNKs. The
  453. // entity body is copied only if HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
  454. // was passed to HttpReceiveHttpRequest().
  455. //
  456. USHORT EntityChunkCount;
  457. PHTTP_DATA_CHUNK pEntityChunks;
  458. //
  459. // SSL connection information.
  460. //
  461. HTTP_RAW_CONNECTION_ID RawConnectionId;
  462. PHTTP_SSL_INFO pSslInfo;
  463. } HTTP_REQUEST, *PHTTP_REQUEST;
  464. //
  465. // Values for HTTP_REQUEST::Flags. Zero or more of these may be ORed together.
  466. //
  467. // HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS - there is more entity body
  468. // to be read for this request. Otherwise, there is no entity body or
  469. // all of the entity body was copied into pEntityChunks.
  470. //
  471. #define HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS 0x00000001
  472. //
  473. // This structure describes an HTTP response.
  474. //
  475. typedef struct _HTTP_RESPONSE
  476. {
  477. ULONG Flags;
  478. //
  479. // The raw HTTP protocol version number.
  480. //
  481. HTTP_VERSION Version;
  482. //
  483. // The HTTP status code (e.g., 200).
  484. //
  485. USHORT StatusCode;
  486. //
  487. // The HTTP reason (e.g., "OK"). This MUST not contain
  488. // non-ASCII characters (i.e., all chars must be in range 0x20-0x7E).
  489. //
  490. USHORT ReasonLength; // in bytes not including the '\0'
  491. PCSTR pReason;
  492. //
  493. // The response headers.
  494. //
  495. HTTP_RESPONSE_HEADERS Headers;
  496. //
  497. // pEntityChunks points to an array of EntityChunkCount HTTP_DATA_CHUNKs.
  498. //
  499. USHORT EntityChunkCount;
  500. PHTTP_DATA_CHUNK pEntityChunks;
  501. } HTTP_RESPONSE, *PHTTP_RESPONSE;
  502. //
  503. // Cache control.
  504. //
  505. //
  506. // This enum defines the available cache policies.
  507. //
  508. typedef enum _HTTP_CACHE_POLICY_TYPE
  509. {
  510. HttpCachePolicyNocache,
  511. HttpCachePolicyUserInvalidates,
  512. HttpCachePolicyTimeToLive,
  513. HttpCachePolicyMaximum
  514. } HTTP_CACHE_POLICY_TYPE, *PHTTP_CACHE_POLICY_TYPE;
  515. //
  516. // Only cache unauthorized GETs + HEADs.
  517. //
  518. typedef struct _HTTP_CACHE_POLICY
  519. {
  520. HTTP_CACHE_POLICY_TYPE Policy;
  521. ULONG SecondsToLive;
  522. } HTTP_CACHE_POLICY, *PHTTP_CACHE_POLICY;
  523. //
  524. // Enum that is used with HttpSetServiceConfiguration(),
  525. // HttpQueryServiceConfiguration(), and HttpDeleteServiceConfiguration() APIs.
  526. //
  527. typedef enum _HTTP_SERVICE_CONFIG_ID
  528. {
  529. HttpServiceConfigIPListenList, // Set, Query & Delete.
  530. HttpServiceConfigSSLCertInfo, // Set, Query & Delete.
  531. HttpServiceConfigUrlAclInfo, // Set, Query & Delete.
  532. HttpServiceConfigMax
  533. } HTTP_SERVICE_CONFIG_ID, *PHTTP_SERVICE_CONFIG_ID;
  534. //
  535. // Generic Query enum that can be used with HttpQueryServiceConfiguration()
  536. //
  537. typedef enum _HTTP_SERVICE_CONFIG_QUERY_TYPE
  538. {
  539. HttpServiceConfigQueryExact,
  540. HttpServiceConfigQueryNext,
  541. HttpServiceConfigQueryMax
  542. } HTTP_SERVICE_CONFIG_QUERY_TYPE, *PHTTP_SERVICE_CONFIG_QUERY_TYPE;
  543. //
  544. // This data structure is used to define a key of the SSL certificate hash
  545. // store.
  546. //
  547. typedef struct _HTTP_SERVICE_CONFIG_SSL_KEY
  548. {
  549. PSOCKADDR pIpPort;
  550. } HTTP_SERVICE_CONFIG_SSL_KEY, *PHTTP_SERVICE_CONFIG_SSL_KEY;
  551. //
  552. // This defines a record for the SSL config store.
  553. //
  554. typedef struct _HTTP_SERVICE_CONFIG_SSL_PARAM
  555. {
  556. ULONG SslHashLength; // Length of the SSL hash (in bytes)
  557. PVOID pSslHash; // Pointer to the SSL hash
  558. GUID AppId; // A unique identifier that can be used to
  559. // identify the app that has set this parameter
  560. PWSTR pSslCertStoreName; // Store name to read the server certificate
  561. // from; defaults to "MY". Certificate must be
  562. // stored in the LOCAL_MACHINE context.
  563. //
  564. // The following settings are used only for client certificates
  565. //
  566. //
  567. // DefaultCertCheckMode is a bit flag with the following semantics
  568. // 0x1 - Client certificate will not be verified for revocation
  569. // 0x2 - Only cached certificate revocation will be used.
  570. // 0x4 - Enable use of the DefaultRevocationFreshnessTime setting
  571. // 0x10000 - No usage check.
  572. DWORD DefaultCertCheckMode;
  573. //
  574. // DefaultRevocationFreshnessTime (seconds) - How often to check for
  575. // an updated Certificate revocation list (CRL). If this value is 0
  576. // then the new CRL is updated only if the previous one expires
  577. //
  578. DWORD DefaultRevocationFreshnessTime;
  579. //
  580. // DefaultRevocationUrlRetrievalTimeout (milliseconds) - Timeout on
  581. // attempt to retrieve certificate revocation list from the remote URL.
  582. //
  583. DWORD DefaultRevocationUrlRetrievalTimeout;
  584. //
  585. // pDefaultSslCtlIdentifier - Restrict the certificate issuers that you
  586. // want to trust. Can be a subset of the certificate issuers that are
  587. // trusted by the machine.
  588. //
  589. PWSTR pDefaultSslCtlIdentifier;
  590. //
  591. // Store name under LOCAL_MACHINE where Ctl identified by
  592. // pDefaultSslCtlIdentifier is stored.
  593. //
  594. PWSTR pDefaultSslCtlStoreName;
  595. //
  596. // Default Flags - see HTTP_SERVICE_CONFIG_SSL_FLAG* below.
  597. //
  598. DWORD DefaultFlags;
  599. } HTTP_SERVICE_CONFIG_SSL_PARAM, *PHTTP_SERVICE_CONFIG_SSL_PARAM;
  600. #define HTTP_SERVICE_CONFIG_SSL_FLAG_USE_DS_MAPPER 0x00000001
  601. #define HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT 0x00000002
  602. #define HTTP_SERVICE_CONFIG_SSL_FLAG_NO_RAW_FILTER 0x00000004
  603. //
  604. // This data structure is used by HttpSetServiceConfiguration() for the
  605. // config ID HttpServiceConfigSSLCertInfo. It's used to add a new record
  606. // to the SSL store.
  607. //
  608. typedef struct _HTTP_SERVICE_CONFIG_SSL_SET
  609. {
  610. HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
  611. HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc;
  612. } HTTP_SERVICE_CONFIG_SSL_SET, *PHTTP_SERVICE_CONFIG_SSL_SET;
  613. //
  614. // This data structure is used by HttpQueryServiceConfiguration() for the
  615. // config ID HttpServiceConfigSSLCertInfo. It's used to query a particular
  616. // record from the SSL store.
  617. //
  618. // If QueryType is HttpServiceConfigQueryExact, then one particular record of
  619. // the type HTTP_SERVICE_CONFIG_SSL_SET is returned. If the QueryType is
  620. // HttpServiceConfigQueryNext, then the next instance of
  621. // HTTP_SERVICE_CONFIG_SSL_SET is returned. In such cases, the dwToken field
  622. // represents the cursor. For the first item, dwToken has to be 0.
  623. // For subsequent items, dwToken has to be incremented by 1,
  624. // until ERROR_NO_MORE_ITEMS is returned.
  625. //
  626. typedef struct _HTTP_SERVICE_CONFIG_SSL_QUERY
  627. {
  628. HTTP_SERVICE_CONFIG_QUERY_TYPE QueryDesc;
  629. HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
  630. DWORD dwToken;
  631. } HTTP_SERVICE_CONFIG_SSL_QUERY, *PHTTP_SERVICE_CONFIG_SSL_QUERY;
  632. //
  633. // Set/Delete IP Listen-Only List record
  634. //
  635. // Used as a parameter to both HttpSetServiceConfiguration() and
  636. // HttpDeleteServiceConfiguration() functions.
  637. //
  638. typedef struct _HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM
  639. {
  640. USHORT AddrLength;
  641. PSOCKADDR pAddress;
  642. } HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM, *PHTTP_SERVICE_CONFIG_IP_LISTEN_PARAM;
  643. //
  644. // Query IP Listen-Only List record.
  645. //
  646. // Parameter to HttpQueryServiceConfiguration() for the config ID
  647. // HttpServiceConfigIPListenList. On successful return, AddrList
  648. // contains an array of AddrCount elements. Caller must provide a
  649. // large enough buffer to hold all elements in one call.
  650. //
  651. // Caller may determine the type of each returned element by examining
  652. // AddrList[i].ss_family. If it's AF_INET, use ((PSOCKADDR_IN) &AddrList[i]);
  653. // otherwise, for AF_INET6, use ((PSOCKADDR_IN6) &AddrList[i])
  654. // to select the appropriate address type.
  655. //
  656. typedef struct _HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY
  657. {
  658. ULONG AddrCount;
  659. SOCKADDR_STORAGE AddrList[ANYSIZE_ARRAY];
  660. } HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY, *PHTTP_SERVICE_CONFIG_IP_LISTEN_QUERY;
  661. //
  662. // URL ACL
  663. //
  664. //
  665. typedef struct _HTTP_SERVICE_CONFIG_URLACL_KEY
  666. {
  667. PWSTR pUrlPrefix;
  668. } HTTP_SERVICE_CONFIG_URLACL_KEY, *PHTTP_SERVICE_CONFIG_URLACL_KEY;
  669. //
  670. // This defines a record for the SSL config store.
  671. //
  672. typedef struct _HTTP_SERVICE_CONFIG_URLACL_PARAM
  673. {
  674. PWSTR pStringSecurityDescriptor;
  675. } HTTP_SERVICE_CONFIG_URLACL_PARAM, *PHTTP_SERVICE_CONFIG_URLACL_PARAM;
  676. //
  677. // This data structure is used by HttpSetServiceConfiguration for the config ID
  678. // HttpServiceConfigUrlAclInfo. It is used to add a new record to the URL ACL
  679. // store.
  680. //
  681. typedef struct _HTTP_SERVICE_CONFIG_URLACL_SET
  682. {
  683. HTTP_SERVICE_CONFIG_URLACL_KEY KeyDesc;
  684. HTTP_SERVICE_CONFIG_URLACL_PARAM ParamDesc;
  685. } HTTP_SERVICE_CONFIG_URLACL_SET, *PHTTP_SERVICE_CONFIG_URLACL_SET;
  686. //
  687. // This data structure is used by HttpQueryServiceConfiguration() for the
  688. // config ID HttpServiceConfigUrlAclInfo. It's used to query a particular
  689. // record from the URL ACL store.
  690. //
  691. // If QueryType is HttpServiceConfigQueryExact, then one particular record of
  692. // the type HTTP_SERVICE_CONFIG_URLACL_SET is returned. If the QueryType is
  693. // HttpServiceConfigQueryNext, then the next instance of
  694. // HTTP_SERVICE_CONFIG_URLACL_SET is returned. In such cases, the dwToken field
  695. // represents the cursor. For the first item, dwToken has to be 0.
  696. // For subsequent items, dwToken has to be incremented by 1,
  697. // until ERROR_NO_MORE_ITEMS is returned.
  698. //
  699. typedef struct _HTTP_SERVICE_CONFIG_URLACL_QUERY
  700. {
  701. HTTP_SERVICE_CONFIG_QUERY_TYPE QueryDesc;
  702. HTTP_SERVICE_CONFIG_URLACL_KEY KeyDesc;
  703. DWORD dwToken;
  704. } HTTP_SERVICE_CONFIG_URLACL_QUERY, *PHTTP_SERVICE_CONFIG_URLACL_QUERY;
  705. //
  706. // Define our API linkage.
  707. //
  708. #if !defined(HTTPAPI_LINKAGE)
  709. #define HTTPAPI_LINKAGE DECLSPEC_IMPORT
  710. #endif // !HTTPAPI_LINKAGE
  711. //
  712. // Initialize/Terminate APIs.
  713. //
  714. //
  715. // Version number to be passed to HttpInitialize(). This is used to ensure
  716. // compatibility between applications and httpapi.dll and http.sys.
  717. //
  718. // This must not be confused with the HTTP Protocol version.
  719. //
  720. typedef struct _HTTPAPI_VERSION
  721. {
  722. USHORT HttpApiMajorVersion;
  723. USHORT HttpApiMinorVersion;
  724. } HTTPAPI_VERSION, *PHTTPAPI_VERSION;
  725. #define HTTPAPI_VERSION_1 {1, 0}
  726. // NOTE: MUST be called once before all other APIs
  727. HTTPAPI_LINKAGE
  728. ULONG
  729. WINAPI
  730. HttpInitialize(
  731. IN HTTPAPI_VERSION Version,
  732. IN ULONG Flags,
  733. IN OUT PVOID pReserved // must be NULL
  734. );
  735. // NOTE: MUST be called after final API call returns.
  736. HTTPAPI_LINKAGE
  737. ULONG
  738. WINAPI
  739. HttpTerminate(
  740. IN ULONG Flags,
  741. IN OUT PVOID pReserved // must be NULL
  742. );
  743. //
  744. // HTTP Request Queue handle
  745. //
  746. // NOTE: call CloseHandle() to release.
  747. HTTPAPI_LINKAGE
  748. ULONG
  749. WINAPI
  750. HttpCreateHttpHandle(
  751. OUT PHANDLE pReqQueueHandle,
  752. IN ULONG Options // Reserved must be 0
  753. );
  754. //
  755. // SSL APIs.
  756. //
  757. HTTPAPI_LINKAGE
  758. ULONG
  759. WINAPI
  760. HttpReceiveClientCertificate(
  761. IN HANDLE ReqQueueHandle,
  762. IN HTTP_CONNECTION_ID ConnectionId,
  763. IN ULONG Flags,
  764. OUT PHTTP_SSL_CLIENT_CERT_INFO pSslClientCertInfo,
  765. IN ULONG SslClientCertInfoSize,
  766. OUT PULONG pBytesReceived OPTIONAL,
  767. IN LPOVERLAPPED pOverlapped
  768. );
  769. //
  770. // URL Configuration APIs.
  771. //
  772. HTTPAPI_LINKAGE
  773. ULONG
  774. WINAPI
  775. HttpAddUrl(
  776. IN HANDLE ReqQueueHandle,
  777. IN PCWSTR pUrlPrefix,
  778. IN PVOID pReserved // must be NULL
  779. );
  780. HTTPAPI_LINKAGE
  781. ULONG
  782. WINAPI
  783. HttpRemoveUrl(
  784. IN HANDLE ReqQueueHandle,
  785. IN PCWSTR pUrlPrefix
  786. );
  787. //
  788. // HTTP Server I/O APIs.
  789. //
  790. HTTPAPI_LINKAGE
  791. ULONG
  792. WINAPI
  793. HttpReceiveHttpRequest(
  794. IN HANDLE ReqQueueHandle,
  795. IN HTTP_REQUEST_ID RequestId,
  796. IN ULONG Flags,
  797. OUT PHTTP_REQUEST pRequestBuffer,
  798. IN ULONG RequestBufferLength,
  799. OUT PULONG pBytesReceived OPTIONAL,
  800. IN LPOVERLAPPED pOverlapped OPTIONAL
  801. );
  802. HTTPAPI_LINKAGE
  803. ULONG
  804. WINAPI
  805. HttpReceiveRequestEntityBody(
  806. IN HANDLE ReqQueueHandle,
  807. IN HTTP_REQUEST_ID RequestId,
  808. IN ULONG Flags,
  809. OUT PVOID pBuffer,
  810. IN ULONG BufferLength,
  811. OUT PULONG pBytesReceived OPTIONAL,
  812. IN LPOVERLAPPED pOverlapped OPTIONAL
  813. );
  814. HTTPAPI_LINKAGE
  815. ULONG
  816. WINAPI
  817. HttpSendHttpResponse(
  818. IN HANDLE ReqQueueHandle,
  819. IN HTTP_REQUEST_ID RequestId,
  820. IN ULONG Flags,
  821. IN PHTTP_RESPONSE pHttpResponse,
  822. IN PVOID pReserved1 OPTIONAL, // must be NULL
  823. OUT PULONG pBytesSent OPTIONAL,
  824. OUT PVOID pReserved2 OPTIONAL, // must be NULL
  825. IN ULONG Reserved3 OPTIONAL, // must be 0
  826. IN LPOVERLAPPED pOverlapped OPTIONAL,
  827. IN PVOID pReserved4 OPTIONAL // must be NULL
  828. );
  829. HTTPAPI_LINKAGE
  830. ULONG
  831. WINAPI
  832. HttpSendResponseEntityBody(
  833. IN HANDLE ReqQueueHandle,
  834. IN HTTP_REQUEST_ID RequestId,
  835. IN ULONG Flags,
  836. IN USHORT EntityChunkCount OPTIONAL,
  837. IN PHTTP_DATA_CHUNK pEntityChunks OPTIONAL,
  838. OUT PULONG pBytesSent OPTIONAL,
  839. OUT PVOID pReserved1 OPTIONAL, // must be NULL
  840. IN ULONG Reserved2 OPTIONAL, // must be 0
  841. IN LPOVERLAPPED pOverlapped OPTIONAL,
  842. IN PVOID pReserved3 OPTIONAL // must be NULL
  843. );
  844. HTTPAPI_LINKAGE
  845. ULONG
  846. WINAPI
  847. HttpWaitForDisconnect(
  848. IN HANDLE ReqQueueHandle,
  849. IN HTTP_CONNECTION_ID ConnectionId,
  850. IN LPOVERLAPPED pOverlapped OPTIONAL
  851. );
  852. //
  853. // Cache manipulation APIs.
  854. //
  855. HTTPAPI_LINKAGE
  856. ULONG
  857. WINAPI
  858. HttpFlushResponseCache(
  859. IN HANDLE ReqQueueHandle,
  860. IN PCWSTR pUrlPrefix,
  861. IN ULONG Flags,
  862. IN LPOVERLAPPED pOverlapped OPTIONAL
  863. );
  864. HTTPAPI_LINKAGE
  865. ULONG
  866. WINAPI
  867. HttpAddFragmentToCache(
  868. IN HANDLE ReqQueueHandle,
  869. IN PCWSTR pUrlPrefix,
  870. IN PHTTP_DATA_CHUNK pDataChunk,
  871. IN PHTTP_CACHE_POLICY pCachePolicy,
  872. IN LPOVERLAPPED pOverlapped OPTIONAL
  873. );
  874. HTTPAPI_LINKAGE
  875. ULONG
  876. WINAPI
  877. HttpReadFragmentFromCache(
  878. IN HANDLE ReqQueueHandle,
  879. IN PCWSTR pUrlPrefix,
  880. IN PHTTP_BYTE_RANGE pByteRange OPTIONAL,
  881. OUT PVOID pBuffer,
  882. IN ULONG BufferLength,
  883. OUT PULONG pBytesRead OPTIONAL,
  884. IN LPOVERLAPPED pOverlapped OPTIONAL
  885. );
  886. //
  887. // Server configuration APIs
  888. //
  889. HTTPAPI_LINKAGE
  890. ULONG
  891. WINAPI
  892. HttpSetServiceConfiguration(
  893. IN HANDLE ServiceHandle, // Reserved, MUST be NULL
  894. IN HTTP_SERVICE_CONFIG_ID ConfigId,
  895. IN PVOID pConfigInformation,
  896. IN ULONG ConfigInformationLength,
  897. IN LPOVERLAPPED pOverlapped // Reserved, MUST be NULL
  898. );
  899. HTTPAPI_LINKAGE
  900. ULONG
  901. WINAPI
  902. HttpDeleteServiceConfiguration(
  903. IN HANDLE ServiceHandle, // Reserved, MUST be NULL
  904. IN HTTP_SERVICE_CONFIG_ID ConfigId,
  905. IN PVOID pConfigInformation,
  906. IN ULONG ConfigInformationLength,
  907. IN LPOVERLAPPED pOverlapped // Reserved, MUST be NULL
  908. );
  909. HTTPAPI_LINKAGE
  910. ULONG
  911. WINAPI
  912. HttpQueryServiceConfiguration(
  913. IN HANDLE ServiceHandle, // Reserved, MUST be NULL
  914. IN HTTP_SERVICE_CONFIG_ID ConfigId,
  915. IN PVOID pInputConfigInformation OPTIONAL,
  916. IN ULONG InputConfigInformationLength OPTIONAL,
  917. IN OUT PVOID pOutputConfigInformation,
  918. IN ULONG OutputConfigInformationLength,
  919. OUT PULONG pReturnLength,
  920. IN LPOVERLAPPED pOverlapped // Reserved, MUST be NULL
  921. );
  922. #ifdef __cplusplus
  923. } // extern "C"
  924. #endif // __cplusplus
  925. #endif // __HTTP_H__