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.

1326 lines
46 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. winhttp.h
  5. Abstract:
  6. Contains manifests, macros, types and prototypes for Windows HTTP Services
  7. --*/
  8. #if !defined(_WINHTTPX_)
  9. #define _WINHTTPX_
  10. ;begin_internal
  11. #if !defined(_WINHTTPXEX_)
  12. #define _WINHTTPXEX_
  13. ;end_internal
  14. /*
  15. * Set up Structure Packing to be 4 bytes for all winhttp structures
  16. */
  17. #if defined(_WIN64)
  18. #include <pshpack8.h>
  19. #else
  20. #include <pshpack4.h>
  21. #endif
  22. ;begin_both
  23. #if defined(__cplusplus)
  24. extern "C" {
  25. #endif
  26. ;end_both
  27. #if !defined(_WINHTTP_INTERNAL_)
  28. #define WINHTTAPI DECLSPEC_IMPORT
  29. #else
  30. ;begin_internal
  31. #define INTERNETAPI
  32. ;end_internal
  33. #define WINHTTAPI
  34. #endif
  35. #define BOOLAPI WINHTTAPI BOOL WINAPI
  36. //
  37. // types
  38. //
  39. typedef LPVOID HINTERNET;
  40. typedef HINTERNET * LPHINTERNET;
  41. typedef WORD INTERNET_PORT;
  42. typedef INTERNET_PORT * LPINTERNET_PORT;
  43. //
  44. // manifests
  45. //
  46. #define INTERNET_DEFAULT_PORT 0 // use the protocol-specific default
  47. #define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP "
  48. #define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS "
  49. // flags for WinHttpOpen():
  50. #define WINHTTP_FLAG_ASYNC 0x10000000 // this session is asynchronous (where supported)
  51. // flags for WinHttpOpenRequest():
  52. #define WINHTTP_FLAG_SECURE 0x00800000 // use PCT/SSL if applicable (HTTPS)
  53. #define WINHTTP_FLAG_ESCAPE_PERCENT 0x00000004
  54. #define WINHTTP_FLAG_NULL_CODEPAGE 0x00000008
  55. #define WINHTTP_FLAG_BYPASS_PROXY_CACHE 0x00000100 // add "pragma: no-cache" request header
  56. #define WINHTTP_FLAG_REFRESH WINHTTP_FLAG_BYPASS_PROXY_CACHE
  57. ;begin_internal
  58. // url-parsing flags added internally
  59. #define WINHTTP_FLAG_DEFAULT_ESCAPE 0x00000010
  60. #define WINHTTP_FLAG_VALID_HOSTNAME 0x00000020
  61. // These flags are superseded by WINHTTP_OPTION_DISABLE_FEATURE
  62. #define INTERNET_FLAG_KEEP_CONNECTION 0x00400000 // use keep-alive semantics
  63. #define INTERNET_FLAG_NO_AUTO_REDIRECT 0x00200000 // don't handle redirections automatically
  64. #define INTERNET_FLAG_NO_COOKIES 0x00080000 // no automatic cookie handling
  65. #define INTERNET_FLAG_NO_AUTH 0x00040000 // no automatic authentication handling
  66. ;end_internal
  67. ;begin_internal
  68. // WARNING: these flags may become unsupported or done in a different way.
  69. // Security Ignore Flags, Allow HttpOpenRequest to overide
  70. // Secure Channel (SSL/PCT) failures of the following types.
  71. #define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 0x00008000 // ex: https:// to http://
  72. #define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 0x00004000 // ex: http:// to https://
  73. #define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 0x00002000 // expired X509 Cert.
  74. #define INTERNET_FLAG_IGNORE_CERT_CN_INVALID 0x00001000 // bad common name in X509 Cert.
  75. #define SECURITY_INTERNET_MASK (INTERNET_FLAG_IGNORE_CERT_CN_INVALID | \
  76. INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | \
  77. INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | \
  78. INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | \
  79. SECURITY_FLAG_IGNORE_UNKNOWN_CA | \
  80. SECURITY_FLAG_IGNORE_WRONG_USAGE | \
  81. SECURITY_FLAG_BREAK_ON_STATUS_SECURE_FAILURE)
  82. ;end_internal
  83. ;begin_internal
  84. // parameter validation masks
  85. #define WINHTTP_OPEN_FLAGS_MASK (WINHTTP_FLAG_ASYNC) // valid flags mask
  86. #define WINHTTP_CONNECT_FLAGS_MASK 0
  87. #define WINHTTP_OPEN_REQUEST_FLAGS_MASK (WINHTTP_FLAG_SECURE | \
  88. WINHTTP_FLAG_ESCAPE_PERCENT | \
  89. WINHTTP_FLAG_NULL_CODEPAGE | \
  90. WINHTTP_FLAG_BYPASS_PROXY_CACHE )
  91. ;end_internal
  92. //
  93. // WINHTTP_ASYNC_RESULT - this structure is returned to the application via
  94. // the callback with WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE. It is not sufficient to
  95. // just return the result of the async operation. If the API failed then the
  96. // app cannot call GetLastError() because the thread context will be incorrect.
  97. // Both the value returned by the async API and any resultant error code are
  98. // made available. The app need not check dwError if dwResult indicates that
  99. // the API succeeded (in this case dwError will be ERROR_SUCCESS)
  100. //
  101. typedef struct
  102. {
  103. DWORD_PTR dwResult; // the HINTERNET, DWORD or BOOL return code from an async API
  104. DWORD dwError; // the error code if the API failed
  105. }
  106. WINHTTP_ASYNC_RESULT, * LPWINHTTP_ASYNC_RESULT;
  107. //
  108. // HTTP_VERSION_INFO - query or set global HTTP version (1.0 or 1.1)
  109. //
  110. typedef struct
  111. {
  112. DWORD dwMajorVersion;
  113. DWORD dwMinorVersion;
  114. }
  115. HTTP_VERSION_INFO, * LPHTTP_VERSION_INFO;
  116. //
  117. // INTERNET_SCHEME - URL scheme type
  118. //
  119. typedef int INTERNET_SCHEME, * LPINTERNET_SCHEME;
  120. #define INTERNET_SCHEME_HTTP (1)
  121. #define INTERNET_SCHEME_HTTPS (2)
  122. ;begin_internal
  123. #define INTERNET_SCHEME_PARTIAL (-2)
  124. #define INTERNET_SCHEME_UNKNOWN (-1)
  125. #define INTERNET_SCHEME_DEFAULT (0)
  126. #define INTERNET_SCHEME_SOCKS (3)
  127. #define INTERNET_SCHEME_FIRST (INTERNET_SCHEME_HTTP)
  128. #define INTERNET_SCHEME_LAST (INTERNET_SCHEME_SOCKS)
  129. ;end_internal
  130. //
  131. // URL_COMPONENTS - the constituent parts of an URL. Used in WinHttpCrackUrl()
  132. // and WinHttpCreateUrl()
  133. //
  134. // For WinHttpCrackUrl(), if a pointer field and its corresponding length field
  135. // are both 0 then that component is not returned. If the pointer field is NULL
  136. // but the length field is not zero, then both the pointer and length fields are
  137. // returned if both pointer and corresponding length fields are non-zero then
  138. // the pointer field points to a buffer where the component is copied. The
  139. // component may be un-escaped, depending on dwFlags
  140. //
  141. // For WinHttpCreateUrl(), the pointer fields should be NULL if the component
  142. // is not required. If the corresponding length field is zero then the pointer
  143. // field is the address of a zero-terminated string. If the length field is not
  144. // zero then it is the string length of the corresponding pointer field
  145. //
  146. #pragma warning( disable : 4121 ) // disable alignment warning
  147. typedef struct
  148. {
  149. DWORD dwStructSize; // size of this structure. Used in version check
  150. LPWSTR lpszScheme; // pointer to scheme name
  151. DWORD dwSchemeLength; // length of scheme name
  152. INTERNET_SCHEME nScheme; // enumerated scheme type (if known)
  153. LPWSTR lpszHostName; // pointer to host name
  154. DWORD dwHostNameLength; // length of host name
  155. INTERNET_PORT nPort; // converted port number
  156. LPWSTR lpszUserName; // pointer to user name
  157. DWORD dwUserNameLength; // length of user name
  158. LPWSTR lpszPassword; // pointer to password
  159. DWORD dwPasswordLength; // length of password
  160. LPWSTR lpszUrlPath; // pointer to URL-path
  161. DWORD dwUrlPathLength; // length of URL-path
  162. LPWSTR lpszExtraInfo; // pointer to extra information (e.g. ?foo or #foo)
  163. DWORD dwExtraInfoLength; // length of extra information
  164. }
  165. URL_COMPONENTSW, * LPURL_COMPONENTSW;
  166. #ifdef UNICODE
  167. typedef URL_COMPONENTSW URL_COMPONENTS;
  168. typedef LPURL_COMPONENTSW LPURL_COMPONENTS;
  169. #endif // UNICODE
  170. #pragma warning( default : 4121 ) // restore alignment warning
  171. //
  172. // WINHTTP_PROXY_INFO - structure supplied with WINHTTP_OPTION_PROXY to get/
  173. // set proxy information on a WinHttpOpen() handle
  174. //
  175. typedef struct
  176. {
  177. DWORD dwAccessType; // see WINHTTP_ACCESS_* types below
  178. LPWSTR lpszProxy; // proxy server list
  179. LPWSTR lpszProxyBypass; // proxy bypass list
  180. }
  181. WINHTTP_PROXY_INFOW;
  182. #ifdef UNICODE
  183. typedef WINHTTP_PROXY_INFOW WINHTTP_PROXY_INFO;
  184. #endif // UNICODE
  185. //
  186. // WINHTTP_CERTIFICATE_INFO lpBuffer - contains the certificate returned from
  187. // the server
  188. //
  189. typedef struct
  190. {
  191. //
  192. // ftExpiry - date the certificate expires.
  193. //
  194. FILETIME ftExpiry;
  195. //
  196. // ftStart - date the certificate becomes valid.
  197. //
  198. FILETIME ftStart;
  199. //
  200. // lpszSubjectInfo - the name of organization, site, and server
  201. // the cert. was issued for.
  202. //
  203. LPTSTR lpszSubjectInfo;
  204. //
  205. // lpszIssuerInfo - the name of orgainzation, site, and server
  206. // the cert was issues by.
  207. //
  208. LPTSTR lpszIssuerInfo;
  209. //
  210. // lpszProtocolName - the name of the protocol used to provide the secure
  211. // connection.
  212. //
  213. LPTSTR lpszProtocolName;
  214. //
  215. // lpszSignatureAlgName - the name of the algorithm used for signing
  216. // the certificate.
  217. //
  218. LPTSTR lpszSignatureAlgName;
  219. //
  220. // lpszEncryptionAlgName - the name of the algorithm used for
  221. // doing encryption over the secure channel (SSL/PCT) connection.
  222. //
  223. LPTSTR lpszEncryptionAlgName;
  224. //
  225. // dwKeySize - size of the key.
  226. //
  227. DWORD dwKeySize;
  228. }
  229. WINHTTP_CERTIFICATE_INFO;
  230. //
  231. // prototypes
  232. //
  233. BOOLAPI
  234. WinHttpTimeFromSystemTime
  235. (
  236. IN CONST SYSTEMTIME *pst, // input GMT time
  237. OUT LPWSTR pwszTime // output string buffer
  238. );
  239. //
  240. // constants for WinHttpTimeFromSystemTime
  241. //
  242. #define WINHTTP_TIME_FORMAT_BUFSIZE 62
  243. BOOLAPI
  244. WinHttpTimeToSystemTime
  245. (
  246. IN LPCWSTR pwszTime, // NULL terminated string
  247. OUT SYSTEMTIME *pst // output in GMT time
  248. );
  249. //
  250. // flags for CrackUrl() and CombineUrl()
  251. //
  252. #define ICU_NO_ENCODE 0x20000000 // Don't convert unsafe characters to escape sequence
  253. #define ICU_DECODE 0x10000000 // Convert %XX escape sequences to characters
  254. #define ICU_NO_META 0x08000000 // Don't convert .. etc. meta path sequences
  255. #define ICU_ENCODE_SPACES_ONLY 0x04000000 // Encode spaces only
  256. #define ICU_BROWSER_MODE 0x02000000 // Special encode/decode rules for browser
  257. #define ICU_ENCODE_PERCENT 0x00001000 // Encode any percent (ASCII25)
  258. // signs encountered, default is to not encode percent.
  259. BOOLAPI
  260. WinHttpCrackUrl
  261. (
  262. IN LPCWSTR pwszUrl,
  263. IN DWORD dwUrlLength,
  264. IN DWORD dwFlags,
  265. IN OUT LPURL_COMPONENTSW lpUrlComponents
  266. );
  267. BOOLAPI
  268. WinHttpCreateUrl
  269. (
  270. IN LPURL_COMPONENTSW lpUrlComponents,
  271. IN DWORD dwFlags,
  272. OUT LPWSTR pwszUrl,
  273. IN OUT LPDWORD lpdwUrlLength
  274. );
  275. BOOLAPI
  276. WinHttpCheckPlatform(void);
  277. //
  278. // flags for WinHttpCrackUrl() and WinHttpCreateUrl()
  279. //
  280. #define ICU_ESCAPE 0x80000000 // (un)escape URL characters
  281. WINHTTAPI
  282. HINTERNET
  283. WINAPI
  284. WinHttpOpen
  285. (
  286. IN LPCWSTR pwszUserAgent,
  287. IN DWORD dwAccessType,
  288. IN LPCWSTR pwszProxyName OPTIONAL,
  289. IN LPCWSTR pwszProxyBypass OPTIONAL,
  290. IN DWORD dwFlags
  291. );
  292. // WinHttpOpen dwAccessType values (also for WINHTTP_PROXY_INFO::dwAccessType)
  293. #define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY 0
  294. #define WINHTTP_ACCESS_TYPE_NO_PROXY 1
  295. #define WINHTTP_ACCESS_TYPE_NAMED_PROXY 3
  296. // WinHttpOpen prettifiers for optional parameters
  297. #define WINHTTP_NO_PROXY_NAME NULL
  298. #define WINHTTP_NO_PROXY_BYPASS NULL
  299. BOOLAPI
  300. WinHttpCloseHandle
  301. (
  302. IN HINTERNET hInternet
  303. );
  304. WINHTTAPI
  305. HINTERNET
  306. WINAPI
  307. WinHttpConnect
  308. (
  309. IN HINTERNET hSession,
  310. IN LPCWSTR pswzServerName,
  311. IN INTERNET_PORT nServerPort,
  312. IN DWORD dwReserved
  313. );
  314. BOOLAPI
  315. WinHttpReadData
  316. (
  317. IN HINTERNET hRequest,
  318. IN LPVOID lpBuffer,
  319. IN DWORD dwNumberOfBytesToRead,
  320. OUT LPDWORD lpdwNumberOfBytesRead
  321. );
  322. BOOLAPI
  323. WinHttpWriteData
  324. (
  325. IN HINTERNET hRequest,
  326. IN LPCVOID lpBuffer,
  327. IN DWORD dwNumberOfBytesToWrite,
  328. OUT LPDWORD lpdwNumberOfBytesWritten
  329. );
  330. BOOLAPI
  331. WinHttpQueryDataAvailable
  332. (
  333. IN HINTERNET hRequest,
  334. OUT LPDWORD lpdwNumberOfBytesAvailable OPTIONAL
  335. );
  336. BOOLAPI
  337. WinHttpQueryOption
  338. (
  339. IN HINTERNET hInternet,
  340. IN DWORD dwOption,
  341. OUT LPVOID lpBuffer OPTIONAL,
  342. IN OUT LPDWORD lpdwBufferLength
  343. );
  344. BOOLAPI
  345. WinHttpSetOption
  346. (
  347. IN HINTERNET hInternet,
  348. IN DWORD dwOption,
  349. IN LPVOID lpBuffer,
  350. IN DWORD dwBufferLength
  351. );
  352. BOOLAPI
  353. WinHttpSetTimeouts
  354. (
  355. IN HINTERNET hInternet, // Session/Request handle.
  356. IN int nResolveTimeout,
  357. IN int nConnectTimeout,
  358. IN int nSendTimeout,
  359. IN int nReceiveTimeout
  360. );
  361. //
  362. // options manifests for WinHttp{Query|Set}Option
  363. //
  364. #define WINHTTP_FIRST_OPTION WINHTTP_OPTION_CALLBACK
  365. #define WINHTTP_OPTION_CALLBACK 1
  366. #define WINHTTP_OPTION_RESOLVE_TIMEOUT 2
  367. #define WINHTTP_OPTION_CONNECT_TIMEOUT 3
  368. #define WINHTTP_OPTION_CONNECT_RETRIES 4
  369. #define WINHTTP_OPTION_SEND_TIMEOUT 5
  370. #define WINHTTP_OPTION_RECEIVE_TIMEOUT 6
  371. #define WINHTTP_OPTION_HANDLE_TYPE 9
  372. #define WINHTTP_OPTION_READ_BUFFER_SIZE 12
  373. #define WINHTTP_OPTION_WRITE_BUFFER_SIZE 13
  374. #define WINHTTP_OPTION_PARENT_HANDLE 21
  375. #define WINHTTP_OPTION_EXTENDED_ERROR 24
  376. #define WINHTTP_OPTION_SECURITY_FLAGS 31
  377. #define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT 32
  378. #define WINHTTP_OPTION_URL 34
  379. #define WINHTTP_OPTION_SECURITY_KEY_BITNESS 36
  380. #define WINHTTP_OPTION_PROXY 38
  381. ;begin_internal
  382. // WINHTTP_OPTION_VERSION is confusing, so we are killing it.
  383. #define WINHTTP_OPTION_VERSION 40
  384. ;end_internal
  385. #define WINHTTP_OPTION_USER_AGENT 41
  386. #define WINHTTP_OPTION_CONTEXT_VALUE 45
  387. #define WINHTTP_OPTION_CLIENT_CERT_CONTEXT 47
  388. #define WINHTTP_OPTION_REQUEST_PRIORITY 58
  389. #define WINHTTP_OPTION_HTTP_VERSION 59
  390. ;begin_internal
  391. #define WINHTTP_OPTION_ERROR_MASK 62
  392. ;end_internal
  393. #define WINHTTP_OPTION_DISABLE_FEATURE 63
  394. ;begin_internal
  395. // Pass in pointer to INTERNET_SECURITY_CONNECTION_INFO to be filled in.
  396. #define WINHTTP_OPTION_SECURITY_CONNECTION_INFO 66
  397. #define WINHTTP_OPTION_DIAGNOSTIC_SOCKET_INFO 67
  398. ;end_internal
  399. #define WINHTTP_OPTION_CODEPAGE 68
  400. #define WINHTTP_OPTION_MAX_CONNS_PER_SERVER 73
  401. #define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER 74
  402. ;begin_internal
  403. #define WINHTTP_OPTION_PER_CONNECTION_OPTION 75
  404. ;end_internal
  405. #define WINHTTP_OPTION_DIGEST_AUTH_UNLOAD 76
  406. #define WINHTTP_OPTION_AUTOLOGON_POLICY 77
  407. #define WINHTTP_OPTION_SERVER_CERT_CONTEXT 78
  408. #define WINHTTP_OPTION_ENABLE_FEATURE 79
  409. #define WINHTTP_OPTION_WORKER_THREAD_COUNT 80
  410. #define WINHTTP_LAST_OPTION WINHTTP_OPTION_WORKER_THREAD_COUNT
  411. #define WINHTTP_OPTION_USERNAME 0x1000
  412. #define WINHTTP_OPTION_PASSWORD 0x1001
  413. #define WINHTTP_OPTION_PROXY_USERNAME 0x1002
  414. #define WINHTTP_OPTION_PROXY_PASSWORD 0x1003
  415. ;begin_internal
  416. #define WINHTTP_LAST_OPTION_INTERNAL WINHTTP_OPTION_AUTOLOGON_POLICY
  417. #define WINHTTP_OPTION_MASK 0x0fff
  418. #define MAX_INTERNET_STRING_OPTION (WINHTTP_OPTION_PROXY_PASSWORD & WINHTTP_OPTION_MASK)
  419. #define NUM_INTERNET_STRING_OPTION (MAX_INTERNET_STRING_OPTION + 1)
  420. ;end_internal
  421. // manifest value for WINHTTP_OPTION_MAX_CONNS_PER_SERVER and WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
  422. #define WINHTTP_CONNS_PER_SERVER_UNLIMITED 0xFFFFFFFF
  423. // values for WINHTTP_OPTION_AUTOLOGON_SECURITY_LEVEL
  424. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM 0
  425. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW 1
  426. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH 2
  427. ;begin_internal
  428. // values for WINHTTP_OPTION_ERROR_MASK
  429. #define INTERNET_ERROR_MASK_COMBINED_SEC_CERT 0x2
  430. ;end_internal
  431. // values for WINHTTP_OPTION_DISABLE_FEATURE
  432. #define WINHTTP_DISABLE_COOKIES 0x00000001
  433. #define WINHTTP_DISABLE_REDIRECTS 0x00000002
  434. #define WINHTTP_DISABLE_AUTHENTICATION 0x00000004
  435. #define WINHTTP_DISABLE_KEEP_ALIVE 0x00000008
  436. // values for WINHTTP_OPTION_ENABLE_FEATURE
  437. #define WINHTTP_ENABLE_SSL_REVOCATION 0x00000001
  438. //
  439. // winhttp handle types
  440. //
  441. #define WINHTTP_HANDLE_TYPE_SESSION 1
  442. #define WINHTTP_HANDLE_TYPE_CONNECT 2
  443. #define WINHTTP_HANDLE_TYPE_REQUEST 3
  444. //
  445. // values for auth schemes
  446. //
  447. #define WINHTTP_AUTH_SCHEME_BASIC 0x00000001
  448. #define WINHTTP_AUTH_SCHEME_NTLM 0x00000002
  449. #define WINHTTP_AUTH_SCHEME_PASSPORT 0x00000004
  450. #define WINHTTP_AUTH_SCHEME_DIGEST 0x00000008
  451. #define WINHTTP_AUTH_SCHEME_NEGOTIATE 0x00000010
  452. ;begin_internal
  453. #define WINHTTP_AUTH_SCHEME_KERBEROS 0x00000020
  454. ;end_internal
  455. // WinHttp supported Authentication Targets
  456. #define WINHTTP_AUTH_TARGET_SERVER 0x00000000
  457. #define WINHTTP_AUTH_TARGET_PROXY 0x00000001
  458. //
  459. // values for WINHTTP_OPTION_SECURITY_FLAGS
  460. //
  461. // query only
  462. #define SECURITY_FLAG_SECURE 0x00000001 // can query only
  463. #define SECURITY_FLAG_STRENGTH_WEAK 0x10000000
  464. #define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000
  465. #define SECURITY_FLAG_STRENGTH_STRONG 0x20000000
  466. #define SECURITY_FLAG_FORTEZZA 0x08000000
  467. ;begin_internal
  468. // setable flags
  469. #define SECURITY_FLAG_IGNORE_REVOCATION 0x00000080
  470. #define SECURITY_FLAG_IGNORE_UNKNOWN_CA 0x00000100
  471. #define SECURITY_FLAG_IGNORE_WRONG_USAGE 0x00000200
  472. #define SECURITY_FLAG_CHECK_REVOCATION 0x00020000
  473. #define SECURITY_FLAG_BREAK_ON_STATUS_SECURE_FAILURE 0x00040000
  474. ;end_internal
  475. // Secure connection error status flags
  476. #define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED 0x00000001
  477. #define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT 0x00000002 // includes wrong usage cases
  478. #define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED 0x00000004
  479. #define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA 0x00000008
  480. #define WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID 0x00000010
  481. #define WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID 0x00000020
  482. #define WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR 0x80000000
  483. //
  484. // callback function for WinHttpSetStatusCallback
  485. //
  486. typedef
  487. VOID
  488. (CALLBACK * WINHTTP_STATUS_CALLBACK)(
  489. IN HINTERNET hInternet,
  490. IN DWORD_PTR dwContext,
  491. IN DWORD dwInternetStatus,
  492. IN LPVOID lpvStatusInformation OPTIONAL,
  493. IN DWORD dwStatusInformationLength
  494. );
  495. typedef WINHTTP_STATUS_CALLBACK * LPWINHTTP_STATUS_CALLBACK;
  496. WINHTTAPI
  497. WINHTTP_STATUS_CALLBACK
  498. WINAPI
  499. WinHttpSetStatusCallback
  500. (
  501. IN HINTERNET hInternet,
  502. IN WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
  503. IN DWORD dwNotificationFlags,
  504. IN DWORD_PTR dwReserved
  505. );
  506. //
  507. // status manifests for WinHttp status callback
  508. //
  509. #define WINHTTP_CALLBACK_STATUS_RESOLVING_NAME 0x00000001
  510. #define WINHTTP_CALLBACK_STATUS_NAME_RESOLVED 0x00000002
  511. #define WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER 0x00000004
  512. #define WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER 0x00000008
  513. #define WINHTTP_CALLBACK_STATUS_SENDING_REQUEST 0x00000010
  514. #define WINHTTP_CALLBACK_STATUS_REQUEST_SENT 0x00000020
  515. #define WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE 0x00000040
  516. #define WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED 0x00000080
  517. #define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION 0x00000100
  518. #define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED 0x00000200
  519. #define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED 0x00000400
  520. #define WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING 0x00000800
  521. #define WINHTTP_CALLBACK_STATUS_DETECTING_PROXY 0x00001000
  522. #define WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE 0x00002000
  523. #define WINHTTP_CALLBACK_STATUS_REDIRECT 0x00004000
  524. #define WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE 0x00008000
  525. #define WINHTTP_CALLBACK_STATUS_SECURE_FAILURE 0x00010000
  526. #define WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE 0x00020000
  527. #define WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE 0x00040000
  528. #define WINHTTP_CALLBACK_STATUS_READ_COMPLETE 0x00080000
  529. #define WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE 0x00100000
  530. #define WINHTTP_CALLBACK_STATUS_REQUEST_ERROR 0x00200000
  531. #define WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE 0x00400000
  532. // API Enums for WINHTTP_CALLBACK_STATUS_REQUEST_ERROR:
  533. #define API_RECEIVE_RESPONSE (1)
  534. #define API_QUERY_DATA_AVAILABLE (2)
  535. #define API_READ_DATA (3)
  536. #define API_WRITE_DATA (4)
  537. #define API_SEND_REQUEST (5)
  538. #define API_UNKNOWN (6)
  539. #define WINHTTP_CALLBACK_FLAG_RESOLVE_NAME (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED)
  540. #define WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER)
  541. #define WINHTTP_CALLBACK_FLAG_SEND_REQUEST (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT | WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE)
  542. #define WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED)
  543. #define WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED)
  544. #define WINHTTP_CALLBACK_FLAG_HANDLES (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING)
  545. #define WINHTTP_CALLBACK_FLAG_DETECTING_PROXY WINHTTP_CALLBACK_STATUS_DETECTING_PROXY
  546. #define WINHTTP_CALLBACK_FLAG_REQUEST_COMPLETE WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE
  547. #define WINHTTP_CALLBACK_FLAG_REDIRECT WINHTTP_CALLBACK_STATUS_REDIRECT
  548. #define WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE
  549. #define WINHTTP_CALLBACK_FLAG_SECURE_FAILURE WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
  550. #define WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
  551. #define WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
  552. #define WINHTTP_CALLBACK_FLAG_READ_COMPLETE WINHTTP_CALLBACK_STATUS_READ_COMPLETE
  553. #define WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE
  554. #define WINHTTP_CALLBACK_FLAG_REQUEST_ERROR WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
  555. ;begin_internal
  556. //ensure that WINHTTP_CALLBACK_FLAG_ALL always matches OR of all the CALLBACKFLAGS
  557. ;end_internal
  558. #define WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS 0xffffffff
  559. //
  560. // if the following value is returned by WinHttpSetStatusCallback, then
  561. // probably an invalid (non-code) address was supplied for the callback
  562. //
  563. #define WINHTTP_INVALID_STATUS_CALLBACK ((WINHTTP_STATUS_CALLBACK)(-1L))
  564. //
  565. // WinHttpQueryHeaders info levels. Generally, there is one info level
  566. // for each potential RFC822/HTTP/MIME header that an HTTP server
  567. // may send as part of a request response.
  568. //
  569. // The WINHTTP_QUERY_RAW_HEADERS info level is provided for clients
  570. // that choose to perform their own header parsing.
  571. //
  572. ;begin_internal
  573. //
  574. // Note that adding any WINHTTP_QUERY_* codes here must be followed
  575. // by an equivlent line in wininet\http\hashgen\hashgen.cpp
  576. // please see that file for further information regarding
  577. // the addition of new HTTP headers
  578. //
  579. ;end_internal
  580. #define WINHTTP_QUERY_MIME_VERSION 0
  581. #define WINHTTP_QUERY_CONTENT_TYPE 1
  582. #define WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING 2
  583. #define WINHTTP_QUERY_CONTENT_ID 3
  584. #define WINHTTP_QUERY_CONTENT_DESCRIPTION 4
  585. #define WINHTTP_QUERY_CONTENT_LENGTH 5
  586. #define WINHTTP_QUERY_CONTENT_LANGUAGE 6
  587. #define WINHTTP_QUERY_ALLOW 7
  588. #define WINHTTP_QUERY_PUBLIC 8
  589. #define WINHTTP_QUERY_DATE 9
  590. #define WINHTTP_QUERY_EXPIRES 10
  591. #define WINHTTP_QUERY_LAST_MODIFIED 11
  592. #define WINHTTP_QUERY_MESSAGE_ID 12
  593. #define WINHTTP_QUERY_URI 13
  594. #define WINHTTP_QUERY_DERIVED_FROM 14
  595. #define WINHTTP_QUERY_COST 15
  596. #define WINHTTP_QUERY_LINK 16
  597. #define WINHTTP_QUERY_PRAGMA 17
  598. #define WINHTTP_QUERY_VERSION 18 // special: part of status line
  599. #define WINHTTP_QUERY_STATUS_CODE 19 // special: part of status line
  600. #define WINHTTP_QUERY_STATUS_TEXT 20 // special: part of status line
  601. #define WINHTTP_QUERY_RAW_HEADERS 21 // special: all headers as ASCIIZ
  602. #define WINHTTP_QUERY_RAW_HEADERS_CRLF 22 // special: all headers
  603. #define WINHTTP_QUERY_CONNECTION 23
  604. #define WINHTTP_QUERY_ACCEPT 24
  605. #define WINHTTP_QUERY_ACCEPT_CHARSET 25
  606. #define WINHTTP_QUERY_ACCEPT_ENCODING 26
  607. #define WINHTTP_QUERY_ACCEPT_LANGUAGE 27
  608. #define WINHTTP_QUERY_AUTHORIZATION 28
  609. #define WINHTTP_QUERY_CONTENT_ENCODING 29
  610. #define WINHTTP_QUERY_FORWARDED 30
  611. #define WINHTTP_QUERY_FROM 31
  612. #define WINHTTP_QUERY_IF_MODIFIED_SINCE 32
  613. #define WINHTTP_QUERY_LOCATION 33
  614. #define WINHTTP_QUERY_ORIG_URI 34
  615. #define WINHTTP_QUERY_REFERER 35
  616. #define WINHTTP_QUERY_RETRY_AFTER 36
  617. #define WINHTTP_QUERY_SERVER 37
  618. #define WINHTTP_QUERY_TITLE 38
  619. #define WINHTTP_QUERY_USER_AGENT 39
  620. #define WINHTTP_QUERY_WWW_AUTHENTICATE 40
  621. #define WINHTTP_QUERY_PROXY_AUTHENTICATE 41
  622. #define WINHTTP_QUERY_ACCEPT_RANGES 42
  623. #define WINHTTP_QUERY_SET_COOKIE 43
  624. #define WINHTTP_QUERY_COOKIE 44
  625. #define WINHTTP_QUERY_REQUEST_METHOD 45 // special: GET/POST etc.
  626. #define WINHTTP_QUERY_REFRESH 46
  627. #define WINHTTP_QUERY_CONTENT_DISPOSITION 47
  628. //
  629. // HTTP 1.1 defined headers
  630. //
  631. #define WINHTTP_QUERY_AGE 48
  632. #define WINHTTP_QUERY_CACHE_CONTROL 49
  633. #define WINHTTP_QUERY_CONTENT_BASE 50
  634. #define WINHTTP_QUERY_CONTENT_LOCATION 51
  635. #define WINHTTP_QUERY_CONTENT_MD5 52
  636. #define WINHTTP_QUERY_CONTENT_RANGE 53
  637. #define WINHTTP_QUERY_ETAG 54
  638. #define WINHTTP_QUERY_HOST 55
  639. #define WINHTTP_QUERY_IF_MATCH 56
  640. #define WINHTTP_QUERY_IF_NONE_MATCH 57
  641. #define WINHTTP_QUERY_IF_RANGE 58
  642. #define WINHTTP_QUERY_IF_UNMODIFIED_SINCE 59
  643. #define WINHTTP_QUERY_MAX_FORWARDS 60
  644. #define WINHTTP_QUERY_PROXY_AUTHORIZATION 61
  645. #define WINHTTP_QUERY_RANGE 62
  646. #define WINHTTP_QUERY_TRANSFER_ENCODING 63
  647. #define WINHTTP_QUERY_UPGRADE 64
  648. #define WINHTTP_QUERY_VARY 65
  649. #define WINHTTP_QUERY_VIA 66
  650. #define WINHTTP_QUERY_WARNING 67
  651. #define WINHTTP_QUERY_EXPECT 68
  652. #define WINHTTP_QUERY_PROXY_CONNECTION 69
  653. #define WINHTTP_QUERY_UNLESS_MODIFIED_SINCE 70
  654. ;begin_internal
  655. // These are not part of HTTP 1.1 yet. We will propose these to the
  656. // HTTP extensions working group. These are required for the client-caps support
  657. // we are doing in conjuntion with IIS.
  658. #define WINHTTP_QUERY_ECHO_REQUEST 71
  659. #define WINHTTP_QUERY_ECHO_REPLY 72
  660. // These are the set of headers that should be added back to a request when
  661. // re-doing a request after a RETRY_WITH response.
  662. #define WINHTTP_QUERY_ECHO_HEADERS 73
  663. #define WINHTTP_QUERY_ECHO_HEADERS_CRLF 74
  664. ;end_internal
  665. #define WINHTTP_QUERY_PROXY_SUPPORT 75
  666. #define WINHTTP_QUERY_AUTHENTICATION_INFO 76
  667. #define WINHTTP_QUERY_PASSPORT_URLS 77
  668. #define WINHTTP_QUERY_MAX 77
  669. //
  670. // WINHTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel
  671. // parameter of WinHttpQueryHeaders() then the lpBuffer parameter contains the name
  672. // of the header we are to query
  673. //
  674. #define WINHTTP_QUERY_CUSTOM 65535
  675. //
  676. // WINHTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel
  677. // parameter of WinHttpQueryHeaders() then the request headers will be queried for the
  678. // request information
  679. //
  680. #define WINHTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000
  681. //
  682. // WINHTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter
  683. // of WinHttpQueryHeaders() AND the header being queried contains date information,
  684. // e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure
  685. // containing the date and time information converted from the header string
  686. //
  687. #define WINHTTP_QUERY_FLAG_SYSTEMTIME 0x40000000
  688. //
  689. // WINHTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of
  690. // HttpQueryHeader(), then the value of the header will be converted to a number
  691. // before being returned to the caller, if applicable
  692. //
  693. #define WINHTTP_QUERY_FLAG_NUMBER 0x20000000
  694. ;begin_internal
  695. #define HTTP_QUERY_MODIFIER_FLAGS_MASK (WINHTTP_QUERY_FLAG_REQUEST_HEADERS \
  696. | WINHTTP_QUERY_FLAG_SYSTEMTIME \
  697. | WINHTTP_QUERY_FLAG_NUMBER \
  698. )
  699. #define HTTP_QUERY_HEADER_MASK (~HTTP_QUERY_MODIFIER_FLAGS_MASK)
  700. ;end_internal
  701. //
  702. // HTTP Response Status Codes:
  703. //
  704. #define HTTP_STATUS_CONTINUE 100 // OK to continue with request
  705. #define HTTP_STATUS_SWITCH_PROTOCOLS 101 // server has switched protocols in upgrade header
  706. #define HTTP_STATUS_OK 200 // request completed
  707. #define HTTP_STATUS_CREATED 201 // object created, reason = new URI
  708. #define HTTP_STATUS_ACCEPTED 202 // async completion (TBS)
  709. #define HTTP_STATUS_PARTIAL 203 // partial completion
  710. #define HTTP_STATUS_NO_CONTENT 204 // no info to return
  711. #define HTTP_STATUS_RESET_CONTENT 205 // request completed, but clear form
  712. #define HTTP_STATUS_PARTIAL_CONTENT 206 // partial GET furfilled
  713. #define HTTP_STATUS_AMBIGUOUS 300 // server couldn't decide what to return
  714. #define HTTP_STATUS_MOVED 301 // object permanently moved
  715. #define HTTP_STATUS_REDIRECT 302 // object temporarily moved
  716. #define HTTP_STATUS_REDIRECT_METHOD 303 // redirection w/ new access method
  717. #define HTTP_STATUS_NOT_MODIFIED 304 // if-modified-since was not modified
  718. #define HTTP_STATUS_USE_PROXY 305 // redirection to proxy, location header specifies proxy to use
  719. #define HTTP_STATUS_REDIRECT_KEEP_VERB 307 // HTTP/1.1: keep same verb
  720. #define HTTP_STATUS_BAD_REQUEST 400 // invalid syntax
  721. #define HTTP_STATUS_DENIED 401 // access denied
  722. #define HTTP_STATUS_PAYMENT_REQ 402 // payment required
  723. #define HTTP_STATUS_FORBIDDEN 403 // request forbidden
  724. #define HTTP_STATUS_NOT_FOUND 404 // object not found
  725. #define HTTP_STATUS_BAD_METHOD 405 // method is not allowed
  726. #define HTTP_STATUS_NONE_ACCEPTABLE 406 // no response acceptable to client found
  727. #define HTTP_STATUS_PROXY_AUTH_REQ 407 // proxy authentication required
  728. #define HTTP_STATUS_REQUEST_TIMEOUT 408 // server timed out waiting for request
  729. #define HTTP_STATUS_CONFLICT 409 // user should resubmit with more info
  730. #define HTTP_STATUS_GONE 410 // the resource is no longer available
  731. #define HTTP_STATUS_LENGTH_REQUIRED 411 // the server refused to accept request w/o a length
  732. #define HTTP_STATUS_PRECOND_FAILED 412 // precondition given in request failed
  733. #define HTTP_STATUS_REQUEST_TOO_LARGE 413 // request entity was too large
  734. #define HTTP_STATUS_URI_TOO_LONG 414 // request URI too long
  735. #define HTTP_STATUS_UNSUPPORTED_MEDIA 415 // unsupported media type
  736. #define HTTP_STATUS_RETRY_WITH 449 // retry after doing the appropriate action.
  737. #define HTTP_STATUS_SERVER_ERROR 500 // internal server error
  738. #define HTTP_STATUS_NOT_SUPPORTED 501 // required not supported
  739. #define HTTP_STATUS_BAD_GATEWAY 502 // error response received from gateway
  740. #define HTTP_STATUS_SERVICE_UNAVAIL 503 // temporarily overloaded
  741. #define HTTP_STATUS_GATEWAY_TIMEOUT 504 // timed out waiting for gateway
  742. #define HTTP_STATUS_VERSION_NOT_SUP 505 // HTTP version not supported
  743. #define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE
  744. #define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP
  745. //
  746. // prototypes
  747. //
  748. WINHTTAPI
  749. HINTERNET
  750. WINAPI
  751. WinHttpOpenRequest
  752. (
  753. IN HINTERNET hConnect,
  754. IN LPCWSTR pwszVerb,
  755. IN LPCWSTR pwszObjectName,
  756. IN LPCWSTR pwszVersion,
  757. IN LPCWSTR pwszReferrer OPTIONAL,
  758. IN LPCWSTR FAR * ppwszAcceptTypes OPTIONAL,
  759. IN DWORD dwFlags
  760. );
  761. // WinHttpOpenRequest prettifers for optional parameters
  762. #define WINHTTP_NO_REFERER NULL
  763. #define WINHTTP_DEFAULT_ACCEPT_TYPES NULL
  764. BOOLAPI
  765. WinHttpAddRequestHeaders
  766. (
  767. IN HINTERNET hRequest,
  768. IN LPCWSTR pwszHeaders,
  769. IN DWORD dwHeadersLength,
  770. IN DWORD dwModifiers
  771. );
  772. //
  773. // values for dwModifiers parameter of WinHttpAddRequestHeaders()
  774. //
  775. #define WINHTTP_ADDREQ_INDEX_MASK 0x0000FFFF
  776. #define WINHTTP_ADDREQ_FLAGS_MASK 0xFFFF0000
  777. //
  778. // WINHTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't
  779. // already exist
  780. //
  781. #define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW 0x10000000
  782. //
  783. // WINHTTP_ADDREQ_FLAG_ADD - if WINHTTP_ADDREQ_FLAG_REPLACE is set but the header is
  784. // not found then if this flag is set, the header is added anyway, so long as
  785. // there is a valid header-value
  786. //
  787. #define WINHTTP_ADDREQ_FLAG_ADD 0x20000000
  788. //
  789. // WINHTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g.
  790. // "Accept: text/*" and "Accept: audio/*" with this flag results in a single
  791. // header: "Accept: text/*, audio/*"
  792. //
  793. #define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA 0x40000000
  794. #define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON 0x01000000
  795. #define WINHTTP_ADDREQ_FLAG_COALESCE WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
  796. //
  797. // WINHTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can
  798. // be supplied in the buffer. If the header to be replaced is not the first
  799. // in a list of headers with the same name, then the relative index should be
  800. // supplied in the low 8 bits of the dwModifiers parameter. If the header-value
  801. // part is missing, then the header is removed
  802. //
  803. #define WINHTTP_ADDREQ_FLAG_REPLACE 0x80000000
  804. BOOLAPI
  805. WinHttpSendRequest
  806. (
  807. IN HINTERNET hRequest,
  808. IN LPCWSTR pwszHeaders OPTIONAL,
  809. IN DWORD dwHeadersLength,
  810. IN LPVOID lpOptional OPTIONAL,
  811. IN DWORD dwOptionalLength,
  812. IN DWORD dwTotalLength,
  813. IN DWORD_PTR dwContext
  814. );
  815. // WinHttpSendRequest prettifiers for optional parameters.
  816. #define WINHTTP_NO_ADDITIONAL_HEADERS NULL
  817. #define WINHTTP_NO_REQUEST_DATA NULL
  818. ;begin_internal
  819. //
  820. // AR_TYPE - Asynchronous Request Type designator. Used as index into array of
  821. // ARB sizes, hence must start at 0
  822. //
  823. typedef enum {
  824. AR_INTERNET_CONNECT = 0, // 0
  825. AR_INTERNET_OPEN_URL, // 1
  826. AR_INTERNET_READ_FILE, // 2
  827. AR_INTERNET_WRITE_FILE, // 3
  828. AR_INTERNET_QUERY_DATA_AVAILABLE, // 4
  829. AR_INTERNET_FIND_NEXT_FILE, // 5
  830. AR_FTP_FIND_FIRST_FILE, // 6
  831. AR_FTP_GET_FILE, // 7
  832. AR_FTP_PUT_FILE, // 8
  833. AR_FTP_DELETE_FILE, // 9
  834. AR_FTP_RENAME_FILE, // 10
  835. AR_FTP_OPEN_FILE, // 11
  836. AR_FTP_CREATE_DIRECTORY, // 12
  837. AR_FTP_REMOVE_DIRECTORY, // 13
  838. AR_FTP_SET_CURRENT_DIRECTORY, // 14
  839. AR_FTP_GET_CURRENT_DIRECTORY, // 15
  840. AR_GOPHER_FIND_FIRST_FILE, // 16
  841. AR_GOPHER_OPEN_FILE, // 17
  842. AR_GOPHER_GET_ATTRIBUTE, // 18
  843. AR_HTTP_SEND_REQUEST, // 19
  844. AR_HTTP_BEGIN_SEND_REQUEST, // 20
  845. AR_HTTP_END_SEND_REQUEST, // 21
  846. AR_READ_PREFETCH, // 22
  847. AR_SYNC_EVENT, // 23
  848. AR_TIMER_EVENT, // 24
  849. AR_HTTP_REQUEST1, // 25
  850. AR_FILE_IO, // 26
  851. AR_INTERNET_READ_FILE_EX, // 27
  852. AR_MAX_REQUEST_TYPE
  853. } AR_TYPE;
  854. ;end_internal
  855. BOOLAPI WinHttpSetCredentials
  856. (
  857. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest.
  858. IN DWORD AuthTargets, // Only WINHTTP_AUTH_TARGET_SERVER and
  859. // WINHTTP_AUTH_TARGET_PROXY are supported
  860. // in this version and they are mutually
  861. // exclusive
  862. IN DWORD AuthScheme, // must be one of the supported Auth Schemes
  863. // returned from WinHttpQueryAuthSchemes(), Apps
  864. // should use the Preferred Scheme returned
  865. IN LPCWSTR pwszUserName, // 1) NULL if default creds is to be used, in
  866. // which case pszPassword will be ignored
  867. IN LPCWSTR pwszPassword, // 1) "" == Blank Password; 2)Parameter ignored
  868. // if pszUserName is NULL; 3) Invalid to pass in
  869. // NULL if pszUserName is not NULL
  870. IN LPVOID pAuthParams
  871. );
  872. BOOLAPI WinHttpQueryAuthSchemes
  873. (
  874. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest
  875. OUT LPDWORD lpdwSupportedSchemes, // a bitmap of available Authentication Schemes
  876. OUT LPDWORD lpdwPreferredScheme, // WinHttp's preferred Authentication Method
  877. OUT LPDWORD pdwAuthTarget
  878. );
  879. BOOLAPI WinHttpQueryAuthParams(
  880. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest
  881. IN DWORD AuthScheme,
  882. OUT LPVOID* pAuthParams // Scheme-specific Advanced auth parameters
  883. );
  884. WINHTTAPI
  885. BOOL
  886. WINAPI
  887. WinHttpReceiveResponse
  888. (
  889. IN HINTERNET hRequest,
  890. IN LPVOID lpReserved
  891. );
  892. BOOLAPI
  893. WinHttpQueryHeaders
  894. (
  895. IN HINTERNET hRequest,
  896. IN DWORD dwInfoLevel,
  897. IN LPCWSTR pwszName OPTIONAL,
  898. OUT LPVOID lpBuffer OPTIONAL,
  899. IN OUT LPDWORD lpdwBufferLength,
  900. IN OUT LPDWORD lpdwIndex OPTIONAL
  901. );
  902. // WinHttpQueryHeaders prettifiers for optional parameters.
  903. #define WINHTTP_HEADER_NAME_BY_INDEX NULL
  904. #define WINHTTP_NO_OUTPUT_BUFFER NULL
  905. #define WINHTTP_NO_HEADER_INDEX NULL
  906. //#if !defined(_WINERROR_)
  907. //
  908. // WinHttp API error returns
  909. //
  910. #define WINHTTP_ERROR_BASE 12000
  911. #define ERROR_WINHTTP_OUT_OF_HANDLES (WINHTTP_ERROR_BASE + 1)
  912. #define ERROR_WINHTTP_TIMEOUT (WINHTTP_ERROR_BASE + 2)
  913. #define ERROR_WINHTTP_INTERNAL_ERROR (WINHTTP_ERROR_BASE + 4)
  914. #define ERROR_WINHTTP_INVALID_URL (WINHTTP_ERROR_BASE + 5)
  915. #define ERROR_WINHTTP_UNRECOGNIZED_SCHEME (WINHTTP_ERROR_BASE + 6)
  916. #define ERROR_WINHTTP_NAME_NOT_RESOLVED (WINHTTP_ERROR_BASE + 7)
  917. #define ERROR_WINHTTP_INVALID_OPTION (WINHTTP_ERROR_BASE + 9)
  918. #define ERROR_WINHTTP_OPTION_NOT_SETTABLE (WINHTTP_ERROR_BASE + 11)
  919. #define ERROR_WINHTTP_SHUTDOWN (WINHTTP_ERROR_BASE + 12)
  920. ;begin_internal
  921. #define ERROR_WINHTTP_INCORRECT_PASSWORD (WINHTTP_ERROR_BASE + 14)
  922. ;end_internal
  923. ;begin_internal
  924. #define WINHTTP_INFO 4L
  925. #define WINHTTP_WARNING 2L
  926. #define WINHTTP_ERROR 1L
  927. void LOG_EVENT(DWORD dwEventType, char* format, ...);
  928. ;end_internal
  929. #define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15)
  930. #define ERROR_WINHTTP_OPERATION_CANCELLED (WINHTTP_ERROR_BASE + 17)
  931. #define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE (WINHTTP_ERROR_BASE + 18)
  932. #define ERROR_WINHTTP_INCORRECT_HANDLE_STATE (WINHTTP_ERROR_BASE + 19)
  933. #define ERROR_WINHTTP_CANNOT_CONNECT (WINHTTP_ERROR_BASE + 29)
  934. #define ERROR_WINHTTP_CONNECTION_ERROR (WINHTTP_ERROR_BASE + 30)
  935. #define ERROR_WINHTTP_RESEND_REQUEST (WINHTTP_ERROR_BASE + 32)
  936. #define ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED (WINHTTP_ERROR_BASE + 44)
  937. //
  938. // WinHttpRequest Component errors
  939. //
  940. #define ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN (WINHTTP_ERROR_BASE + 100)
  941. #define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND (WINHTTP_ERROR_BASE + 101)
  942. #define ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND (WINHTTP_ERROR_BASE + 102)
  943. //
  944. // HTTP API errors
  945. //
  946. #define ERROR_WINHTTP_HEADER_NOT_FOUND (WINHTTP_ERROR_BASE + 150)
  947. #define ERROR_WINHTTP_INVALID_SERVER_RESPONSE (WINHTTP_ERROR_BASE + 152)
  948. #define ERROR_WINHTTP_INVALID_QUERY_REQUEST (WINHTTP_ERROR_BASE + 154)
  949. #define ERROR_WINHTTP_HEADER_ALREADY_EXISTS (WINHTTP_ERROR_BASE + 155)
  950. #define ERROR_WINHTTP_REDIRECT_FAILED (WINHTTP_ERROR_BASE + 156)
  951. ;begin_internal
  952. #define ERROR_WINHTTP_NOT_REDIRECTED (WINHTTP_ERROR_BASE + 160)
  953. ;end_internal
  954. //
  955. // additional WinHttp API error codes
  956. //
  957. #define ERROR_WINHTTP_NOT_INITIALIZED (WINHTTP_ERROR_BASE + 172)
  958. #define ERROR_WINHTTP_SECURE_FAILURE (WINHTTP_ERROR_BASE + 175)
  959. #define WINHTTP_ERROR_LAST ERROR_WINHTTP_SECURE_FAILURE
  960. //#endif // !defined(_WINERROR_)
  961. ;begin_internal
  962. #if defined(INCLUDE_CACHE)
  963. // Cache control flags
  964. // Control expiry behaviour
  965. #define CACHE_FLAG_SYNC_MODE_AUTOMATIC 0x00000010
  966. #define CACHE_FLAG_SYNC_MODE_ALWAYS 0x00000020
  967. #define CACHE_FLAG_SYNC_MODE_ONCE_PER_SESSION 0x00000040
  968. #define CACHE_FLAG_SYNC_MODE_NEVER 0x00000080
  969. #define CACHE_FLAG_BGUPDATE 0x00000100
  970. #define CACHE_FLAG_ALWAYS_RESYNCHRONIZE 0x00000200
  971. #define CACHE_FLAG_DISABLE_CACHE_WRITE 0x00000400
  972. #define CACHE_FLAG_DISABLE_CACHE_READ 0x00000800
  973. #define CACHE_FLAG_DISABLE_SSL_CACHING 0x00001000
  974. #define CACHE_FLAG_MAKE_PERSISTENT 0x00002000
  975. #define CACHE_FLAG_FWD_BACK 0x00004000
  976. #define CACHE_FLAG_OFFLINE_BROWSING CACHE_FLAG_DISABLE_CACHE_READ | CACHE_FLAG_DISABLE_CACHE_WRITE
  977. #define CACHE_FLAG_DEFAULT_SETTING CACHE_FLAG_SYNC_MODE_AUTOMATIC
  978. #define WINHTTP_CACHE_FLAGS_MASK ( CACHE_FLAG_SYNC_MODE_AUTOMATIC | \
  979. CACHE_FLAG_SYNC_MODE_ALWAYS | \
  980. CACHE_FLAG_SYNC_MODE_ONCE_PER_SESSION | \
  981. CACHE_FLAG_SYNC_MODE_NEVER | \
  982. CACHE_FLAG_BGUPDATE | \
  983. CACHE_FLAG_ALWAYS_RESYNCHRONIZE | \
  984. CACHE_FLAG_DISABLE_CACHE_WRITE | \
  985. CACHE_FLAG_DISABLE_CACHE_READ | \
  986. CACHE_FLAG_MAKE_PERSISTENT | \
  987. CACHE_FLAG_FWD_BACK | \
  988. CACHE_FLAG_OFFLINE_BROWSING | \
  989. CACHE_FLAG_DEFAULT_SETTING)
  990. #undef WINHTTP_OPEN_FLAGS_MASK
  991. #define WINHTTP_OPEN_FLAGS_MASK (WINHTTP_CACHE_FLAGS_MASK | \
  992. WINHTTP_FLAG_ASYNC)
  993. WINHTTAPI
  994. HINTERNET
  995. WINAPI
  996. WinHttpCacheOpen(
  997. IN LPCWSTR pszAgentW,
  998. IN DWORD dwAccessType,
  999. IN LPCWSTR pszProxyW OPTIONAL,
  1000. IN LPCWSTR pszProxyBypassW OPTIONAL,
  1001. IN DWORD dwFlags
  1002. );
  1003. WINHTTAPI
  1004. HINTERNET
  1005. WINAPI
  1006. WinHttpCacheOpenRequest(
  1007. IN HINTERNET hConnect,
  1008. IN LPCWSTR lpszVerb,
  1009. IN LPCWSTR lpszObjectName,
  1010. IN LPCWSTR lpszVersion,
  1011. IN LPCWSTR lpszReferrer OPTIONAL,
  1012. IN LPCWSTR FAR * lplpszAcceptTypes OPTIONAL,
  1013. IN DWORD dwFlags
  1014. );
  1015. BOOLAPI
  1016. WinHttpCacheSendRequest(
  1017. IN HINTERNET hRequest,
  1018. IN LPCWSTR lpszHeaders,
  1019. IN DWORD dwHeadersLength,
  1020. IN LPVOID lpOptional,
  1021. IN DWORD dwOptionalLength,
  1022. IN DWORD dwTotalLength,
  1023. IN DWORD_PTR dwContext
  1024. );
  1025. BOOLAPI
  1026. WinHttpCacheReceiveResponse(
  1027. IN HINTERNET hRequest,
  1028. IN LPVOID lpBuffersOut
  1029. );
  1030. BOOLAPI
  1031. WinHttpCacheQueryDataAvailable(
  1032. IN HINTERNET hRequest,
  1033. OUT LPDWORD lpdwNumberOfBytesAvailable
  1034. );
  1035. BOOLAPI
  1036. WinHttpCacheReadData(
  1037. IN HINTERNET hRequest,
  1038. IN LPVOID lpBuffer,
  1039. IN DWORD dwNumberOfBytesToRead,
  1040. OUT LPDWORD lpdwNumberOfBytesRead
  1041. );
  1042. BOOLAPI
  1043. WinHttpCacheCloseHandle(
  1044. IN HINTERNET hInternet
  1045. );
  1046. #endif
  1047. ;end_internal
  1048. ;begin_both
  1049. #if defined(__cplusplus)
  1050. }
  1051. #endif
  1052. ;end_both
  1053. /*
  1054. * Return packing to whatever it was before we
  1055. * entered this file
  1056. */
  1057. #include <poppack.h>
  1058. ;begin_internal
  1059. #endif // !define(_WINHTTPXEX_)
  1060. ;end_internal
  1061. #endif // !defined(_WINHTTPX_)