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.

1349 lines
37 KiB

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