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.

1913 lines
67 KiB

  1. /*++
  2. Copyright (c) 1995-2000 Microsoft Corporation
  3. Module Name:
  4. winhttpx.h
  5. Abstract:
  6. Contains manifests, macros, types and prototypes for Microsoft Windows
  7. Internet Extensions
  8. --*/
  9. #if !defined(_WINHTTPX_)
  10. #define _WINHTTPX_
  11. ;begin_internal
  12. #if !defined(_WINHTTPXEX_)
  13. #define _WINHTTPXEX_
  14. ;end_internal
  15. /*
  16. * Set up Structure Packing to be 4 bytes
  17. * for all wininet structures
  18. */
  19. #if defined(_WIN64)
  20. #include <pshpack8.h>
  21. #else
  22. #include <pshpack4.h>
  23. #endif
  24. ;begin_both
  25. #if defined(__cplusplus)
  26. extern "C" {
  27. #endif
  28. ;end_both
  29. #if !defined(_WINX32_)
  30. #define INTERNETAPI DECLSPEC_IMPORT
  31. #else
  32. #define INTERNETAPI
  33. #endif
  34. #define BOOLAPI INTERNETAPI BOOL WINAPI
  35. #ifdef MAP_WININET_TO_WINHTTP // assumes #ifdef UNICODE
  36. #define InternetTimeFromSystemTime WinHttpTimeFromSystemTime
  37. #define InternetTimeToSystemTime WinHttpTimeToSystemTime
  38. #define InternetCrackUrl WinHttpCrackUrl
  39. #define InternetCreateUrl WinHttpCreateUrl
  40. #define InternetOpen WinHttpOpen
  41. #define InternetSetStatusCallback WinHttpSetStatusCallback
  42. #define InternetSetOption WinHttpSetOption
  43. #define InternetQueryOption WinHttpQueryOption
  44. #define InternetConnect(h,s,port,user,pass,svc,flag,ctx) \
  45. WinHttpConnect(h,s,port,flag,ctx)
  46. #define HttpOpenRequest WinHttpOpenRequest
  47. #define HttpAddRequestHeaders WinHttpAddRequestHeaders
  48. #define HttpSendRequest(h,ph,cbh,pr,cbr)\
  49. WinHttpSendRequest(h,ph,cbh,pr,cbr,cbr,0)
  50. #define HttpSendRequestEx(h,pbi,pbo,dw,c)\
  51. WinHttpSendRequest(h, \
  52. (pbi)->lpcszHeader, \
  53. (pbi)->dwHeadersLength, \
  54. (pbi)->lpvBuffer, \
  55. (pbi)->dwBufferLength, \
  56. (pbi)->dwBufferTotal, \
  57. 0)
  58. #define InternetWriteFile(h,p,cb,pcb)\
  59. WinHttpWriteData(h,p,cb,pcb,0)
  60. #define HttpEndRequest WinHttpReceiveResponse
  61. #define HttpQueryInfo WinHttpQueryHeaders
  62. #define InternetQueryDataAvailable WinHttpQueryDataAvailable
  63. #define InternetReadFile(h,p,cb,pcb)\
  64. WinHttpReadData(h,p,cb,pcb,0)
  65. #define InternetCloseHandle WinHttpCloseHandle
  66. #define InternetOpenUrl WinHttpOpenUrl
  67. #endif // MAP_WININET_TO_WINHTTP
  68. //
  69. // internet types
  70. //
  71. typedef LPVOID HINTERNET;
  72. typedef HINTERNET * LPHINTERNET;
  73. typedef WORD INTERNET_PORT;
  74. typedef INTERNET_PORT * LPINTERNET_PORT;
  75. //
  76. // WinHttp APIs
  77. //
  78. //
  79. // manifests
  80. //
  81. #define INTERNET_INVALID_PORT_NUMBER 0 // use the protocol-specific default
  82. #define INTERNET_DEFAULT_FTP_PORT 21 // default for FTP servers
  83. #define INTERNET_DEFAULT_GOPHER_PORT 70 // " " gopher "
  84. #define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP "
  85. #define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS "
  86. #define INTERNET_DEFAULT_SOCKS_PORT 1080 // default for SOCKS firewall servers.
  87. //
  88. // maximum field lengths (arbitrary)
  89. //
  90. #define INTERNET_MAX_HOST_NAME_LENGTH 256
  91. #define INTERNET_MAX_USER_NAME_LENGTH 128
  92. #define INTERNET_MAX_PASSWORD_LENGTH 128
  93. #define INTERNET_MAX_REALM_LENGTH 128
  94. #define INTERNET_MAX_PORT_NUMBER_LENGTH 5 // INTERNET_PORT is unsigned short
  95. #define INTERNET_MAX_PORT_NUMBER_VALUE 65535 // maximum unsigned short value
  96. #define INTERNET_MAX_PATH_LENGTH 2048
  97. #define INTERNET_MAX_SCHEME_LENGTH 32 // longest protocol name length
  98. #define INTERNET_MAX_URL_LENGTH (INTERNET_MAX_SCHEME_LENGTH \
  99. + sizeof("://") \
  100. + INTERNET_MAX_PATH_LENGTH)
  101. //
  102. // values returned by WinHttpQueryOption() with INTERNET_OPTION_KEEP_CONNECTION:
  103. //
  104. #define INTERNET_KEEP_ALIVE_UNKNOWN ((DWORD)-1)
  105. #define INTERNET_KEEP_ALIVE_ENABLED 1
  106. #define INTERNET_KEEP_ALIVE_DISABLED 0
  107. //
  108. // flags returned by WinHttpQueryOption() with INTERNET_OPTION_REQUEST_FLAGS
  109. //
  110. #define INTERNET_REQFLAG_FROM_CACHE 0x00000001 // response came from cache
  111. #define INTERNET_REQFLAG_ASYNC 0x00000002 // request was made asynchronously
  112. #define INTERNET_REQFLAG_VIA_PROXY 0x00000004 // request was made via a proxy
  113. #define INTERNET_REQFLAG_NO_HEADERS 0x00000008 // orginal response contained no headers
  114. #define INTERNET_REQFLAG_PASSIVE 0x00000010 // FTP: passive-mode connection
  115. #define INTERNET_REQFLAG_CACHE_WRITE_DISABLED 0x00000040 // HTTPS: this request not cacheable
  116. #define INTERNET_REQFLAG_NET_TIMEOUT 0x00000080 // w/ _FROM_CACHE: net request timed out
  117. //
  118. // manifest value for INTERNET_OPTION_MAX_CONNS_PER_SERVER and INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
  119. //
  120. #define INTERNET_CONNS_PER_SERVER_UNLIMITED 0xFFFFFFFF
  121. //
  122. // flags common to open functions (not WinHttpOpen()):
  123. //
  124. #define INTERNET_FLAG_RELOAD 0x80000000 // retrieve the original item
  125. //
  126. // flags for WinHttpOpenUrl():
  127. //
  128. #define INTERNET_FLAG_RAW_DATA 0x40000000 // FTP/gopher find: receive the item as raw (structured) data
  129. #define INTERNET_FLAG_EXISTING_CONNECT 0x20000000 // FTP: use existing WinHttpConnect handle for server if possible
  130. //
  131. // additional cache flags
  132. //
  133. #define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 // don't write this item to the cache
  134. #define INTERNET_FLAG_DONT_CACHE INTERNET_FLAG_NO_CACHE_WRITE
  135. #define INTERNET_FLAG_MAKE_PERSISTENT 0x02000000 // make this item persistent in cache
  136. #define INTERNET_FLAG_FROM_CACHE 0x01000000 // use offline semantics
  137. #define INTERNET_FLAG_OFFLINE INTERNET_FLAG_FROM_CACHE
  138. //
  139. // additional flags
  140. //
  141. #define INTERNET_FLAG_SECURE 0x00800000 // use PCT/SSL if applicable (HTTP)
  142. #define INTERNET_FLAG_KEEP_CONNECTION 0x00400000 // use keep-alive semantics
  143. #define INTERNET_FLAG_NO_AUTO_REDIRECT 0x00200000 // don't handle redirections automatically
  144. #define INTERNET_FLAG_READ_PREFETCH 0x00100000 // do background read prefetch
  145. #define INTERNET_FLAG_NO_COOKIES 0x00080000 // no automatic cookie handling
  146. #define INTERNET_FLAG_NO_AUTH 0x00040000 // no automatic authentication handling
  147. ;begin_internal
  148. #define INTERNET_FLAG_UNUSED_1 0x00020000
  149. ;end_internal
  150. #define INTERNET_FLAG_CACHE_IF_NET_FAIL 0x00010000 // return cache file if net request fails
  151. //
  152. // Security Ignore Flags, Allow HttpOpenRequest to overide
  153. // Secure Channel (SSL/PCT) failures of the following types.
  154. //
  155. #define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 0x00008000 // ex: https:// to http://
  156. #define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 0x00004000 // ex: http:// to https://
  157. #define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 0x00002000 // expired X509 Cert.
  158. #define INTERNET_FLAG_IGNORE_CERT_CN_INVALID 0x00001000 // bad common name in X509 Cert.
  159. //
  160. // more caching flags
  161. //
  162. #define INTERNET_FLAG_RESYNCHRONIZE 0x00000800 // asking wininet to update an item if it is newer
  163. #define INTERNET_FLAG_HYPERLINK 0x00000400 // asking wininet to do hyperlinking semantic which works right for scripts
  164. #define INTERNET_FLAG_NO_UI 0x00000200 // no cookie popup
  165. #define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100 // asking wininet to add "pragma: no-cache"
  166. #define INTERNET_FLAG_CACHE_ASYNC 0x00000080 // ok to perform lazy cache-write
  167. #define INTERNET_FLAG_FORMS_SUBMIT 0x00000040 // this is a forms submit
  168. #define INTERNET_FLAG_FWD_BACK 0x00000020 // fwd-back button op
  169. #define INTERNET_FLAG_NEED_FILE 0x00000010 // need a file for this request
  170. #define INTERNET_FLAG_MUST_CACHE_REQUEST INTERNET_FLAG_NEED_FILE
  171. ;begin_internal
  172. //
  173. //Note that INTERNET_FLAG_BGUPDATE has the same value
  174. //as INTERNET_FLAG_DONT_DECODE
  175. //
  176. #define INTERNET_FLAG_BGUPDATE 0x00000008
  177. ;end_internal
  178. // flags and values for codepages and escaping of object
  179. #define INTERNET_FLAG_ESCAPE_PERCENT 0x00000004
  180. #define INTERNET_FLAG_DONT_DECODE 0x00000008
  181. ;begin_internal
  182. //
  183. //Note that INTERNET_FLAG_DEFAULT_ESCAPE has the same value
  184. //as INTERNET_FLAG_NEED_FILE
  185. //Note that INTERNET_FLAG_VALID_HOSTNAME has the same value
  186. //as INTERNET_FLAG_FWD_BACK
  187. //
  188. #define INTERNET_FLAG_DEFAULT_ESCAPE 0x00000010
  189. #define INTERNET_FLAG_VALID_HOSTNAME 0x00000020
  190. ;end_internal
  191. //
  192. // flags field masks
  193. //
  194. #define SECURITY_INTERNET_MASK (INTERNET_FLAG_IGNORE_CERT_CN_INVALID | \
  195. INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | \
  196. INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | \
  197. INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP )
  198. #define INTERNET_FLAGS_MASK (INTERNET_FLAG_RELOAD \
  199. | INTERNET_FLAG_RAW_DATA \
  200. | INTERNET_FLAG_EXISTING_CONNECT \
  201. | INTERNET_FLAG_NO_CACHE_WRITE \
  202. | INTERNET_FLAG_MAKE_PERSISTENT \
  203. | INTERNET_FLAG_FROM_CACHE \
  204. | INTERNET_FLAG_SECURE \
  205. | INTERNET_FLAG_KEEP_CONNECTION \
  206. | INTERNET_FLAG_NO_AUTO_REDIRECT \
  207. | INTERNET_FLAG_READ_PREFETCH \
  208. | INTERNET_FLAG_NO_COOKIES \
  209. | INTERNET_FLAG_NO_AUTH \
  210. | INTERNET_FLAG_CACHE_IF_NET_FAIL \
  211. | SECURITY_INTERNET_MASK \
  212. | INTERNET_FLAG_RESYNCHRONIZE \
  213. | INTERNET_FLAG_HYPERLINK \
  214. | INTERNET_FLAG_NO_UI \
  215. | INTERNET_FLAG_PRAGMA_NOCACHE \
  216. | INTERNET_FLAG_CACHE_ASYNC \
  217. | INTERNET_FLAG_FORMS_SUBMIT \
  218. | INTERNET_FLAG_NEED_FILE \
  219. | INTERNET_FLAG_FWD_BACK \
  220. | INTERNET_FLAG_BGUPDATE \
  221. | INTERNET_FLAG_ESCAPE_PERCENT \
  222. )
  223. #define INTERNET_ERROR_MASK_INSERT_CDROM 0x1
  224. #define INTERNET_ERROR_MASK_COMBINED_SEC_CERT 0x2
  225. #define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG 0X4
  226. #define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8
  227. #define INTERNET_OPTIONS_MASK (~INTERNET_FLAGS_MASK)
  228. //
  229. // common per-API flags (new APIs)
  230. //
  231. #define WININET_API_FLAG_ASYNC 0x00000001 // force async operation
  232. #define WININET_API_FLAG_SYNC 0x00000004 // force sync operation
  233. #define WININET_API_FLAG_USE_CONTEXT 0x00000008 // use value supplied in dwContext (even if 0)
  234. //
  235. // INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter
  236. // then no call-backs will be made for that API
  237. //
  238. #define INTERNET_NO_CALLBACK 0
  239. //
  240. // structures/types
  241. //
  242. //
  243. // INTERNET_SCHEME - enumerated URL scheme type
  244. //
  245. typedef enum {
  246. INTERNET_SCHEME_PARTIAL = -2,
  247. INTERNET_SCHEME_UNKNOWN = -1,
  248. INTERNET_SCHEME_DEFAULT = 0,
  249. INTERNET_SCHEME_HTTP,
  250. INTERNET_SCHEME_HTTPS,
  251. INTERNET_SCHEME_FILE,
  252. INTERNET_SCHEME_SOCKS,
  253. INTERNET_SCHEME_RES,
  254. INTERNET_SCHEME_FIRST = INTERNET_SCHEME_HTTP,
  255. INTERNET_SCHEME_LAST = INTERNET_SCHEME_RES
  256. } INTERNET_SCHEME, * LPINTERNET_SCHEME;
  257. //
  258. // INTERNET_ASYNC_RESULT - this structure is returned to the application via
  259. // the callback with INTERNET_STATUS_REQUEST_COMPLETE. It is not sufficient to
  260. // just return the result of the async operation. If the API failed then the
  261. // app cannot call GetLastError() because the thread context will be incorrect.
  262. // Both the value returned by the async API and any resultant error code are
  263. // made available. The app need not check dwError if dwResult indicates that
  264. // the API succeeded (in this case dwError will be ERROR_SUCCESS)
  265. //
  266. typedef struct {
  267. //
  268. // dwResult - the HINTERNET, DWORD or BOOL return code from an async API
  269. //
  270. DWORD dwResult;
  271. //
  272. // dwError - the error code if the API failed
  273. //
  274. DWORD dwError;
  275. } INTERNET_ASYNC_RESULT, * LPINTERNET_ASYNC_RESULT;
  276. ;begin_internal
  277. //
  278. // INTERNET_DIAGNOSTIC_SOCKET_INFO - info about the socket in use
  279. // (diagnostic purposes only, hence internal)
  280. //
  281. typedef struct {
  282. DWORD_PTR Socket;
  283. DWORD SourcePort;
  284. DWORD DestPort;
  285. DWORD Flags;
  286. } INTERNET_DIAGNOSTIC_SOCKET_INFO, * LPINTERNET_DIAGNOSTIC_SOCKET_INFO;
  287. //
  288. // INTERNET_DIAGNOSTIC_SOCKET_INFO.Flags definitions
  289. //
  290. #define IDSI_FLAG_KEEP_ALIVE 0x00000001 // set if from keep-alive pool
  291. #define IDSI_FLAG_SECURE 0x00000002 // set if secure connection
  292. #define IDSI_FLAG_PROXY 0x00000004 // set if using proxy
  293. #define IDSI_FLAG_TUNNEL 0x00000008 // set if tunnelling through proxy
  294. ;end_internal
  295. //
  296. // INTERNET_PROXY_INFO - structure supplied with INTERNET_OPTION_PROXY to get/
  297. // set proxy information on a WinHttpOpen() handle
  298. //
  299. typedef struct {
  300. //
  301. // dwAccessType - INTERNET_OPEN_TYPE_DIRECT, INTERNET_OPEN_TYPE_PROXY, or
  302. // INTERNET_OPEN_TYPE_PRECONFIG (set only)
  303. //
  304. DWORD dwAccessType;
  305. //
  306. // lpszProxy - proxy server list
  307. //
  308. LPCTSTR lpszProxy;
  309. //
  310. // lpszProxyBypass - proxy bypass list
  311. //
  312. LPCTSTR lpszProxyBypass;
  313. } INTERNET_PROXY_INFO, * LPINTERNET_PROXY_INFO;
  314. //
  315. // INTERNET_PER_CONN_OPTION_LIST - set per-connection options such as proxy
  316. // and autoconfig info
  317. //
  318. // Set and queried using WinHttp[Set|Query]Option with
  319. // INTERNET_OPTION_PER_CONNECTION_OPTION
  320. //
  321. typedef struct {
  322. DWORD dwOption; // option to be queried or set
  323. union {
  324. DWORD dwValue; // dword value for the option
  325. LPWSTR pszValue; // pointer to string value for the option
  326. FILETIME ftValue; // file-time value for the option
  327. } Value;
  328. } INTERNET_PER_CONN_OPTIONW, * LPINTERNET_PER_CONN_OPTIONW;
  329. #ifdef UNICODE
  330. typedef INTERNET_PER_CONN_OPTIONW INTERNET_PER_CONN_OPTION;
  331. typedef LPINTERNET_PER_CONN_OPTIONW LPINTERNET_PER_CONN_OPTION;
  332. #endif // UNICODE
  333. typedef struct {
  334. DWORD dwSize; // size of the INTERNET_PER_CONN_OPTION_LIST struct
  335. LPWSTR pszConnection; // connection name to set/query options
  336. DWORD dwOptionCount; // number of options to set/query
  337. DWORD dwOptionError; // on error, which option failed
  338. LPINTERNET_PER_CONN_OPTIONW pOptions;
  339. // array of options to set/query
  340. } INTERNET_PER_CONN_OPTION_LISTW, * LPINTERNET_PER_CONN_OPTION_LISTW;
  341. #ifdef UNICODE
  342. typedef INTERNET_PER_CONN_OPTION_LISTW INTERNET_PER_CONN_OPTION_LIST;
  343. typedef LPINTERNET_PER_CONN_OPTION_LISTW LPINTERNET_PER_CONN_OPTION_LIST;
  344. #endif // UNICODE
  345. //
  346. // Options used in INTERNET_PER_CONN_OPTON struct
  347. //
  348. #define INTERNET_PER_CONN_FLAGS 1
  349. #define INTERNET_PER_CONN_PROXY_SERVER 2
  350. #define INTERNET_PER_CONN_PROXY_BYPASS 3
  351. #define INTERNET_PER_CONN_AUTOCONFIG_URL 4
  352. #define INTERNET_PER_CONN_AUTODISCOVERY_FLAGS 5
  353. ;begin_internal
  354. #define INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL 6
  355. #define INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS 7
  356. #define INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME 8
  357. #define INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL 9
  358. ;end_internal
  359. //
  360. // PER_CONN_FLAGS
  361. //
  362. #define PROXY_TYPE_DIRECT 0x00000001 // direct to net
  363. #define PROXY_TYPE_PROXY 0x00000002 // via named proxy
  364. #define PROXY_TYPE_AUTO_PROXY_URL 0x00000004 // autoproxy URL
  365. #define PROXY_TYPE_AUTO_DETECT 0x00000008 // use autoproxy detection
  366. //
  367. // INTERNET_VERSION_INFO - version information returned via
  368. // WinHttpQueryOption(..., INTERNET_OPTION_VERSION, ...)
  369. //
  370. typedef struct {
  371. DWORD dwMajorVersion;
  372. DWORD dwMinorVersion;
  373. } INTERNET_VERSION_INFO, * LPINTERNET_VERSION_INFO;
  374. //
  375. // HTTP_VERSION_INFO - query or set global HTTP version (1.0 or 1.1)
  376. //
  377. typedef struct {
  378. DWORD dwMajorVersion;
  379. DWORD dwMinorVersion;
  380. } HTTP_VERSION_INFO, * LPHTTP_VERSION_INFO;
  381. //
  382. // INTERNET_CONNECTED_INFO - information used to set the global connected state
  383. //
  384. typedef struct {
  385. //
  386. // dwConnectedState - new connected/disconnected state.
  387. // See INTERNET_STATE_CONNECTED, etc.
  388. //
  389. DWORD dwConnectedState;
  390. //
  391. // dwFlags - flags controlling connected->disconnected (or disconnected->
  392. // connected) transition. See below
  393. //
  394. DWORD dwFlags;
  395. } INTERNET_CONNECTED_INFO, * LPINTERNET_CONNECTED_INFO;
  396. ;begin_internal
  397. #define INTERNET_ONLINE_OFFLINE_INFO INTERNET_CONNECTED_INFO
  398. #define LPINTERNET_ONLINE_OFFLINE_INFO LPINTERNET_CONNECTED_INFO
  399. #define dwOfflineState dwConnectedState
  400. ;end_internal
  401. //
  402. // flags for INTERNET_CONNECTED_INFO dwFlags
  403. //
  404. //
  405. // ISO_FORCE_DISCONNECTED - if set when putting Wininet into disconnected mode,
  406. // all outstanding requests will be aborted with a cancelled error
  407. //
  408. #define ISO_FORCE_DISCONNECTED 0x00000001
  409. ;begin_internal
  410. #define ISO_FORCE_OFFLINE ISO_FORCE_DISCONNECTED
  411. ;end_internal
  412. //
  413. // URL_COMPONENTS - the constituent parts of an URL. Used in WinHttpCrackUrl()
  414. // and WinHttpCreateUrl()
  415. //
  416. // For WinHttpCrackUrl(), if a pointer field and its corresponding length field
  417. // are both 0 then that component is not returned. If the pointer field is NULL
  418. // but the length field is not zero, then both the pointer and length fields are
  419. // returned if both pointer and corresponding length fields are non-zero then
  420. // the pointer field points to a buffer where the component is copied. The
  421. // component may be un-escaped, depending on dwFlags
  422. //
  423. // For WinHttpCreateUrl(), the pointer fields should be NULL if the component
  424. // is not required. If the corresponding length field is zero then the pointer
  425. // field is the address of a zero-terminated string. If the length field is not
  426. // zero then it is the string length of the corresponding pointer field
  427. //
  428. #pragma warning( disable : 4121 ) // disable alignment warning
  429. typedef struct {
  430. DWORD dwStructSize; // size of this structure. Used in version check
  431. LPWSTR lpszScheme; // pointer to scheme name
  432. DWORD dwSchemeLength; // length of scheme name
  433. INTERNET_SCHEME nScheme; // enumerated scheme type (if known)
  434. LPWSTR lpszHostName; // pointer to host name
  435. DWORD dwHostNameLength; // length of host name
  436. INTERNET_PORT nPort; // converted port number
  437. LPWSTR lpszUserName; // pointer to user name
  438. DWORD dwUserNameLength; // length of user name
  439. LPWSTR lpszPassword; // pointer to password
  440. DWORD dwPasswordLength; // length of password
  441. LPWSTR lpszUrlPath; // pointer to URL-path
  442. DWORD dwUrlPathLength; // length of URL-path
  443. LPWSTR lpszExtraInfo; // pointer to extra information (e.g. ?foo or #foo)
  444. DWORD dwExtraInfoLength; // length of extra information
  445. } URL_COMPONENTSW, * LPURL_COMPONENTSW;
  446. #ifdef UNICODE
  447. typedef URL_COMPONENTSW URL_COMPONENTS;
  448. typedef LPURL_COMPONENTSW LPURL_COMPONENTS;
  449. #endif // UNICODE
  450. #pragma warning( default : 4121 ) // restore alignment warning
  451. //
  452. // INTERNET_CERTIFICATE_INFO lpBuffer - contains the certificate returned from
  453. // the server
  454. //
  455. typedef struct {
  456. //
  457. // ftExpiry - date the certificate expires.
  458. //
  459. FILETIME ftExpiry;
  460. //
  461. // ftStart - date the certificate becomes valid.
  462. //
  463. FILETIME ftStart;
  464. //
  465. // lpszSubjectInfo - the name of organization, site, and server
  466. // the cert. was issued for.
  467. //
  468. LPTSTR lpszSubjectInfo;
  469. //
  470. // lpszIssuerInfo - the name of orgainzation, site, and server
  471. // the cert was issues by.
  472. //
  473. LPTSTR lpszIssuerInfo;
  474. //
  475. // lpszProtocolName - the name of the protocol used to provide the secure
  476. // connection.
  477. //
  478. LPTSTR lpszProtocolName;
  479. //
  480. // lpszSignatureAlgName - the name of the algorithm used for signing
  481. // the certificate.
  482. //
  483. LPTSTR lpszSignatureAlgName;
  484. //
  485. // lpszEncryptionAlgName - the name of the algorithm used for
  486. // doing encryption over the secure channel (SSL/PCT) connection.
  487. //
  488. LPTSTR lpszEncryptionAlgName;
  489. //
  490. // dwKeySize - size of the key.
  491. //
  492. DWORD dwKeySize;
  493. } INTERNET_CERTIFICATE_INFO, * LPINTERNET_CERTIFICATE_INFO;
  494. ;begin_internal
  495. #ifdef __WINCRYPT_H__
  496. #ifdef ALGIDDEF
  497. //
  498. // INTERNET_SECURITY_INFO - contains information about certificate
  499. // and encryption settings for a connection.
  500. //
  501. #define INTERNET_SECURITY_INFO_DEFINED
  502. typedef struct {
  503. //
  504. // dwSize - Size of INTERNET_SECURITY_INFO structure.
  505. //
  506. DWORD dwSize;
  507. //
  508. // pCertificate - Cert context pointing to leaf of certificate chain.
  509. //
  510. PCCERT_CONTEXT pCertificate;
  511. //
  512. // Start SecPkgContext_ConnectionInfo
  513. // The following members must match those
  514. // of the SecPkgContext_ConnectionInfo
  515. // sspi structure (schnlsp.h)
  516. //
  517. //
  518. // dwProtocol - Protocol that this connection was made with
  519. // (PCT, SSL2, SSL3, etc)
  520. //
  521. DWORD dwProtocol;
  522. //
  523. // aiCipher - Cipher that this connection as made with
  524. //
  525. ALG_ID aiCipher;
  526. //
  527. // dwCipherStrength - Strength (in bits) that this connection
  528. // was made with;
  529. //
  530. DWORD dwCipherStrength;
  531. //
  532. // aiHash - Hash that this connection as made with
  533. //
  534. ALG_ID aiHash;
  535. //
  536. // dwHashStrength - Strength (in bits) that this connection
  537. // was made with;
  538. //
  539. DWORD dwHashStrength;
  540. //
  541. // aiExch - Key Exchange type that this connection as made with
  542. //
  543. ALG_ID aiExch;
  544. //
  545. // dwExchStrength - Strength (in bits) that this connection
  546. // was made with;
  547. //
  548. DWORD dwExchStrength;
  549. } INTERNET_SECURITY_INFO, * LPINTERNET_SECURITY_INFO;
  550. typedef struct {
  551. //
  552. // dwSize - size of INTERNET_SECURITY_CONNECTION_INFO
  553. //
  554. DWORD dwSize;
  555. // fSecure - Is this a secure connection.
  556. BOOL fSecure;
  557. //
  558. // dwProtocol - Protocol that this connection was made with
  559. // (PCT, SSL2, SSL3, etc)
  560. //
  561. DWORD dwProtocol;
  562. //
  563. // aiCipher - Cipher that this connection as made with
  564. //
  565. ALG_ID aiCipher;
  566. //
  567. // dwCipherStrength - Strength (in bits) that this connection
  568. // was made with;
  569. //
  570. DWORD dwCipherStrength;
  571. //
  572. // aiHash - Hash that this connection as made with
  573. //
  574. ALG_ID aiHash;
  575. //
  576. // dwHashStrength - Strength (in bits) that this connection
  577. // was made with;
  578. //
  579. DWORD dwHashStrength;
  580. //
  581. // aiExch - Key Exchange type that this connection as made with
  582. //
  583. ALG_ID aiExch;
  584. //
  585. // dwExchStrength - Strength (in bits) that this connection
  586. // was made with;
  587. //
  588. DWORD dwExchStrength;
  589. } INTERNET_SECURITY_CONNECTION_INFO , * LPINTERNET_SECURITY_CONNECTION_INFO;
  590. #endif // ALGIDDEF
  591. #endif // __WINCRYPT_H__
  592. ;end_internal
  593. //
  594. // INTERNET_BUFFERS - combines headers and data. May be chained for e.g. file
  595. // upload or scatter/gather operations. For chunked read/write, lpcszHeader
  596. // contains the chunked-ext
  597. //
  598. typedef struct _INTERNET_BUFFERSW {
  599. DWORD dwStructSize; // used for API versioning. Set to sizeof(INTERNET_BUFFERS)
  600. struct _INTERNET_BUFFERSW * Next; // chain of buffers
  601. LPCWSTR lpcszHeader; // pointer to headers (may be NULL)
  602. DWORD dwHeadersLength; // length of headers if not NULL
  603. DWORD dwHeadersTotal; // size of headers if not enough buffer
  604. LPVOID lpvBuffer; // pointer to data buffer (may be NULL)
  605. DWORD dwBufferLength; // length of data buffer if not NULL
  606. DWORD dwBufferTotal; // total size of chunk, or content-length if not chunked
  607. DWORD dwOffsetLow; // used for read-ranges (only used in HttpSendRequest2)
  608. DWORD dwOffsetHigh;
  609. } INTERNET_BUFFERSW, * LPINTERNET_BUFFERSW;
  610. #ifdef UNICODE
  611. typedef INTERNET_BUFFERSW INTERNET_BUFFERS;
  612. typedef LPINTERNET_BUFFERSW LPINTERNET_BUFFERS;
  613. #endif // UNICODE
  614. //
  615. // prototypes
  616. //
  617. BOOLAPI
  618. WinHttpTimeFromSystemTime(
  619. IN CONST SYSTEMTIME *pst, // input GMT time
  620. IN DWORD dwRFC, // RFC format
  621. OUT LPWSTR lpszTime, // output string buffer
  622. IN DWORD cbTime // output buffer size
  623. );
  624. //
  625. // constants for WinHttpTimeFromSystemTime
  626. //
  627. #define INTERNET_RFC1123_FORMAT 0
  628. #define INTERNET_RFC1123_BUFSIZE 30
  629. BOOLAPI
  630. WinHttpTimeToSystemTime(
  631. IN LPCWSTR lpszTime, // NULL terminated string
  632. OUT SYSTEMTIME *pst, // output in GMT time
  633. IN DWORD dwReserved
  634. );
  635. ;begin_internal
  636. BOOLAPI
  637. InternetDebugGetLocalTime(
  638. OUT SYSTEMTIME * pstLocalTime,
  639. OUT DWORD * pdwReserved
  640. );
  641. ;end_internal
  642. //
  643. // flags for CrackUrl() and CombineUrl()
  644. //
  645. #define ICU_NO_ENCODE 0x20000000 // Don't convert unsafe characters to escape sequence
  646. #define ICU_DECODE 0x10000000 // Convert %XX escape sequences to characters
  647. #define ICU_NO_META 0x08000000 // Don't convert .. etc. meta path sequences
  648. #define ICU_ENCODE_SPACES_ONLY 0x04000000 // Encode spaces only
  649. #define ICU_BROWSER_MODE 0x02000000 // Special encode/decode rules for browser
  650. #define ICU_ENCODE_PERCENT 0x00001000 // Encode any percent (ASCII25)
  651. // signs encountered, default is to not encode percent.
  652. BOOLAPI
  653. WinHttpCrackUrl(
  654. IN LPCWSTR lpszUrl,
  655. IN DWORD dwUrlLength,
  656. IN DWORD dwFlags,
  657. IN OUT LPURL_COMPONENTSW lpUrlComponents
  658. );
  659. BOOLAPI
  660. WinHttpCreateUrl(
  661. IN LPURL_COMPONENTSW lpUrlComponents,
  662. IN DWORD dwFlags,
  663. OUT LPWSTR lpszUrl,
  664. IN OUT LPDWORD lpdwUrlLength
  665. );
  666. //
  667. // flags for WinHttpCrackUrl() and WinHttpCreateUrl()
  668. //
  669. #define ICU_ESCAPE 0x80000000 // (un)escape URL characters
  670. #define ICU_USERNAME 0x40000000 // use internal username & password
  671. INTERNETAPI
  672. HINTERNET
  673. WINAPI
  674. WinHttpOpen(
  675. IN LPCWSTR lpszAgent,
  676. IN DWORD dwAccessType,
  677. IN LPCWSTR lpszProxy OPTIONAL,
  678. IN LPCWSTR lpszProxyBypass OPTIONAL,
  679. IN DWORD dwFlags
  680. );
  681. //
  682. // access types for WinHttpOpen()
  683. //
  684. #define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 0 // prevent using java/script/INS
  685. #define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
  686. #define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
  687. // no autoproxy support in WinHttp, so PRECONFIG is equivalent to PRECONFIG_WITH_NO_AUTOPROXY
  688. #define INTERNET_OPEN_TYPE_PRECONFIG INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
  689. //
  690. // old names for access types
  691. //
  692. #define PRE_CONFIG_INTERNET_ACCESS INTERNET_OPEN_TYPE_PRECONFIG
  693. #define LOCAL_INTERNET_ACCESS INTERNET_OPEN_TYPE_DIRECT
  694. #define CERN_PROXY_INTERNET_ACCESS INTERNET_OPEN_TYPE_PROXY
  695. BOOLAPI
  696. WinHttpCloseHandle(
  697. IN HINTERNET hInternet
  698. );
  699. INTERNETAPI
  700. HINTERNET
  701. WINAPI
  702. WinHttpConnect(
  703. IN HINTERNET hInternet,
  704. IN LPCWSTR lpszServerName,
  705. IN INTERNET_PORT nServerPort,
  706. IN DWORD dwFlags,
  707. IN DWORD_PTR dwContext
  708. );
  709. // service types for WinHttpConnect()
  710. #define INTERNET_SERVICE_HTTP 3
  711. INTERNETAPI
  712. HINTERNET
  713. WINAPI
  714. WinHttpOpenUrl(
  715. IN HINTERNET hInternet,
  716. IN LPCWSTR lpszUrl,
  717. IN LPCWSTR lpszHeaders OPTIONAL,
  718. IN DWORD dwHeadersLength,
  719. IN DWORD dwFlags,
  720. IN DWORD_PTR dwContext
  721. );
  722. BOOLAPI
  723. WinHttpReadData(
  724. IN HINTERNET hFile,
  725. IN LPVOID lpBuffer,
  726. IN DWORD dwNumberOfBytesToRead,
  727. OUT LPDWORD lpdwNumberOfBytesRead,
  728. IN DWORD dwFlags
  729. );
  730. ;begin_internal
  731. //
  732. // flags for InternetReadFileEx()
  733. //
  734. #define IRF_ASYNC WININET_API_FLAG_ASYNC
  735. #define IRF_SYNC WININET_API_FLAG_SYNC
  736. #define IRF_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT
  737. #define IRF_NO_WAIT 0x00000008
  738. ;end_internal
  739. BOOLAPI
  740. WinHttpWriteData(
  741. IN HINTERNET hFile,
  742. IN LPCVOID lpBuffer,
  743. IN DWORD dwNumberOfBytesToWrite,
  744. OUT LPDWORD lpdwNumberOfBytesWritten,
  745. DWORD dwFlags
  746. );
  747. BOOLAPI
  748. WinHttpQueryDataAvailable(
  749. IN HINTERNET hFile,
  750. OUT LPDWORD lpdwNumberOfBytesAvailable OPTIONAL,
  751. IN DWORD dwFlags,
  752. IN DWORD_PTR dwContext
  753. );
  754. BOOLAPI
  755. WinHttpQueryOption(
  756. IN HINTERNET hInternet OPTIONAL,
  757. IN DWORD dwOption,
  758. OUT LPVOID lpBuffer OPTIONAL,
  759. IN OUT LPDWORD lpdwBufferLength
  760. );
  761. BOOLAPI
  762. WinHttpSetOption(
  763. IN HINTERNET hInternet OPTIONAL,
  764. IN DWORD dwOption,
  765. IN LPVOID lpBuffer,
  766. IN DWORD dwBufferLength
  767. );
  768. BOOLAPI
  769. WinHttpSetTimeouts(
  770. IN HINTERNET hInternet, // Session/Request handle.
  771. IN DWORD dwResolveTimeout,
  772. IN DWORD dwConnectTimeout,
  773. IN DWORD dwSendTimeout,
  774. IN DWORD dwReceiveTimeout
  775. );
  776. //
  777. // options manifests for WinHttp{Query|Set}Option
  778. //
  779. #define INTERNET_OPTION_USERNAME 0x1000
  780. #define INTERNET_OPTION_PASSWORD 0x1001
  781. #define INTERNET_OPTION_PROXY_USERNAME 0x1002
  782. #define INTERNET_OPTION_PROXY_PASSWORD 0x1003
  783. ;begin_internal
  784. #define INTERNET_OPTION_MASK 0x0fff
  785. #define MAX_INTERNET_STRING_OPTION (INTERNET_OPTION_PROXY_PASSWORD & INTERNET_OPTION_MASK)
  786. #define NUM_INTERNET_STRING_OPTION (MAX_INTERNET_STRING_OPTION + 1)
  787. ;end_internal
  788. #ifdef MAP_WININET_TO_WINHTTP
  789. #define INTERNET_FIRST_OPTION WINHTTP_FIRST_OPTION
  790. #define INTERNET_OPTION_CALLBACK WINHTTP_OPTION_CALLBACK
  791. #define INTERNET_OPTION_RESOLVE_TIMEOUT WINHTTP_OPTION_RESOLVE_TIMEOUT
  792. #define INTERNET_OPTION_CONNECT_TIMEOUT WINHTTP_OPTION_CONNECT_TIMEOUT
  793. #define INTERNET_OPTION_CONNECT_RETRIES WINHTTP_OPTION_CONNECT_RETRIES
  794. #define INTERNET_OPTION_SEND_TIMEOUT WINHTTP_OPTION_SEND_TIMEOUT
  795. #define INTERNET_OPTION_RECEIVE_TIMEOUT WINHTTP_OPTION_RECEIVE_TIMEOUT
  796. #define INTERNET_OPTION_HANDLE_TYPE WINHTTP_OPTION_HANDLE_TYPE
  797. #define INTERNET_OPTION_READ_BUFFER_SIZE WINHTTP_OPTION_READ_BUFFER_SIZE
  798. #define INTERNET_OPTION_WRITE_BUFFER_SIZE WINHTTP_OPTION_WRITE_BUFFER_SIZE
  799. #define INTERNET_OPTION_PARENT_HANDLE WINHTTP_OPTION_PARENT_HANDLE
  800. #define INTERNET_OPTION_REQUEST_FLAGS WINHTTP_OPTION_REQUEST_FLAGS
  801. #define INTERNET_OPTION_EXTENDED_ERROR WINHTTP_OPTION_EXTENDED_ERROR
  802. #define INTERNET_OPTION_SECURITY_FLAGS WINHTTP_OPTION_SECURITY_FLAGS
  803. #define INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT
  804. #define INTERNET_OPTION_URL WINHTTP_OPTION_URL
  805. #define INTERNET_OPTION_SECURITY_CERTIFICATE WINHTTP_OPTION_SECURITY_CERTIFICATE
  806. #define INTERNET_OPTION_SECURITY_KEY_BITNESS WINHTTP_OPTION_SECURITY_KEY_BITNESS
  807. #define INTERNET_OPTION_PROXY WINHTTP_OPTION_PROXY
  808. #define INTERNET_OPTION_VERSION WINHTTP_OPTION_VERSION
  809. #define INTERNET_OPTION_USER_AGENT WINHTTP_OPTION_USER_AGENT
  810. #define INTERNET_OPTION_CONTEXT_VALUE WINHTTP_OPTION_CONTEXT_VALUE
  811. #define INTERNET_OPTION_CLIENT_CERT_CONTEXT WINHTTP_OPTION_CLIENT_CERT_CONTEXT
  812. #define INTERNET_OPTION_POLICY WINHTTP_OPTION_POLICY
  813. #define INTERNET_OPTION_REQUEST_PRIORITY WINHTTP_OPTION_REQUEST_PRIORITY
  814. #define INTERNET_OPTION_HTTP_VERSION WINHTTP_OPTION_HTTP_VERSION
  815. #define INTERNET_OPTION_ERROR_MASK WINHTTP_OPTION_ERROR_MASK
  816. #define INTERNET_OPTION_CONTROL_SEND_TIMEOUT WINHTTP_OPTION_SEND_TIMEOUT
  817. #define INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT WINHTTP_OPTION_RECEIVE_TIMEOUT
  818. #define INTERNET_OPTION_DATA_SEND_TIMEOUT WINHTTP_OPTION_SEND_TIMEOUT
  819. #define INTERNET_OPTION_DATA_RECEIVE_TIMEOUT WINHTTP_OPTION_RECEIVE_TIMEOUT
  820. #define INTERNET_OPTION_CODEPAGE WINHTTP_OPTION_CODEPAGE
  821. #define INTERNET_OPTION_MAX_CONNS_PER_SERVER WINHTTP_OPTION_MAX_CONNS_PER_SERVER
  822. #define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
  823. #define INTERNET_OPTION_PER_CONNECTION_OPTION WINHTTP_OPTION_PER_CONNECTION_OPTION
  824. #define INTERNET_OPTION_DIGEST_AUTH_UNLOAD WINHTTP_OPTION_DIGEST_AUTH_UNLOAD
  825. #define INTERNET_LAST_OPTION WINHTTP_LAST_OPTION
  826. #endif // def MAP_WININET_TO_WINHTTP
  827. #define WINHTTP_FIRST_OPTION INTERNET_OPTION_CALLBACK
  828. #define WINHTTP_OPTION_CALLBACK 1
  829. #define WINHTTP_OPTION_RESOLVE_TIMEOUT 2
  830. #define WINHTTP_OPTION_CONNECT_TIMEOUT 3
  831. #define WINHTTP_OPTION_CONNECT_RETRIES 4
  832. #define WINHTTP_OPTION_SEND_TIMEOUT 5
  833. #define WINHTTP_OPTION_RECEIVE_TIMEOUT 6
  834. #define WINHTTP_OPTION_HANDLE_TYPE 9
  835. #define WINHTTP_OPTION_READ_BUFFER_SIZE 12
  836. #define WINHTTP_OPTION_WRITE_BUFFER_SIZE 13
  837. #define WINHTTP_OPTION_PARENT_HANDLE 21
  838. #define WINHTTP_OPTION_REQUEST_FLAGS 23
  839. #define WINHTTP_OPTION_EXTENDED_ERROR 24
  840. #define WINHTTP_OPTION_SECURITY_FLAGS 31
  841. #define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT 32
  842. #define WINHTTP_OPTION_URL 34
  843. #define WINHTTP_OPTION_SECURITY_CERTIFICATE 35
  844. #define WINHTTP_OPTION_SECURITY_KEY_BITNESS 36
  845. #define WINHTTP_OPTION_PROXY 38
  846. #define WINHTTP_OPTION_VERSION 40
  847. #define WINHTTP_OPTION_USER_AGENT 41
  848. #define WINHTTP_OPTION_CONTEXT_VALUE 45
  849. #define WINHTTP_OPTION_CLIENT_CERT_CONTEXT 47
  850. #define WINHTTP_OPTION_POLICY 48
  851. #define WINHTTP_OPTION_REQUEST_PRIORITY 58
  852. #define WINHTTP_OPTION_HTTP_VERSION 59
  853. #define WINHTTP_OPTION_ERROR_MASK 62
  854. ;begin_internal
  855. // Pass in pointer to INTERNET_SECURITY_CONNECTION_INFO to be filled in.
  856. #define WINHTTP_OPTION_SECURITY_CONNECTION_INFO 66
  857. #define WINHTTP_OPTION_DIAGNOSTIC_SOCKET_INFO 67
  858. ;end_internal
  859. #define WINHTTP_OPTION_CODEPAGE 68
  860. #define WINHTTP_OPTION_MAX_CONNS_PER_SERVER 73
  861. #define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER 74
  862. #define WINHTTP_OPTION_PER_CONNECTION_OPTION 75
  863. #define WINHTTP_OPTION_DIGEST_AUTH_UNLOAD 76
  864. #define WINHTTP_OPTION_AUTOLOGON_POLICY 77
  865. #define WINHTTP_LAST_OPTION WINHTTP_OPTION_AUTOLOGON_POLICY
  866. ;begin_internal
  867. #define WINHTTP_LAST_OPTION_INTERNAL WINHTTP_OPTION_AUTOLOGON_POLICY
  868. ;end_internal
  869. //
  870. // handle types
  871. //
  872. #define INTERNET_HANDLE_TYPE_INTERNET 1
  873. #define INTERNET_HANDLE_TYPE_CONNECT_FTP 2
  874. #define INTERNET_HANDLE_TYPE_CONNECT_GOPHER 3
  875. #define INTERNET_HANDLE_TYPE_CONNECT_HTTP 4
  876. #define INTERNET_HANDLE_TYPE_FTP_FIND 5
  877. #define INTERNET_HANDLE_TYPE_FTP_FIND_HTML 6
  878. #define INTERNET_HANDLE_TYPE_FTP_FILE 7
  879. #define INTERNET_HANDLE_TYPE_FTP_FILE_HTML 8
  880. #define INTERNET_HANDLE_TYPE_GOPHER_FIND 9
  881. #define INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML 10
  882. #define INTERNET_HANDLE_TYPE_GOPHER_FILE 11
  883. #define INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML 12
  884. #define INTERNET_HANDLE_TYPE_HTTP_REQUEST 13
  885. #define INTERNET_HANDLE_TYPE_FILE_REQUEST 14
  886. //
  887. // values for auth schemes
  888. //
  889. #define WINHTTP_AUTH_SCHEME_BASIC 0x00000001
  890. #define WINHTTP_AUTH_SCHEME_NTLM 0x00000002
  891. #define WINHTTP_AUTH_SCHEME_PASSPORT 0x00000004
  892. #define WINHTTP_AUTH_SCHEME_DIGEST 0x00000008
  893. #define WINHTTP_AUTH_SCHEME_NEGOTIATE 0x00000010
  894. ;begin_internal
  895. #define WINHTTP_AUTH_SCHEME_KERBEROS 0x00000020
  896. ;end_internal
  897. // WinHttp supported Authentication Targets
  898. #define WINHTTP_AUTH_TARGET_SERVER 0x00000000
  899. #define WINHTTP_AUTH_TARGET_PROXY 0x00000001
  900. //
  901. // values for INTERNET_OPTION_AUTOLOGON_SECURITY_LEVEL
  902. //
  903. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM 0
  904. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW 1
  905. #define WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH 2
  906. //
  907. // values for INTERNET_OPTION_SECURITY_FLAGS
  908. //
  909. // query only
  910. #define SECURITY_FLAG_SECURE 0x00000001 // can query only
  911. #define SECURITY_FLAG_STRENGTH_WEAK 0x10000000
  912. #define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000
  913. #define SECURITY_FLAG_STRENGTH_STRONG 0x20000000
  914. #define SECURITY_FLAG_UNKNOWNBIT 0x80000000
  915. #define SECURITY_FLAG_FORTEZZA 0x08000000
  916. #define SECURITY_FLAG_NORMALBITNESS SECURITY_FLAG_STRENGTH_WEAK
  917. // The following are unused
  918. #define SECURITY_FLAG_SSL 0x00000002
  919. #define SECURITY_FLAG_SSL3 0x00000004
  920. #define SECURITY_FLAG_PCT 0x00000008
  921. #define SECURITY_FLAG_PCT4 0x00000010
  922. #define SECURITY_FLAG_IETFSSL4 0x00000020
  923. // The following are for backwards compatability only.
  924. #define SECURITY_FLAG_40BIT SECURITY_FLAG_STRENGTH_WEAK
  925. #define SECURITY_FLAG_128BIT SECURITY_FLAG_STRENGTH_STRONG
  926. #define SECURITY_FLAG_56BIT SECURITY_FLAG_STRENGTH_MEDIUM
  927. // setable flags
  928. #define SECURITY_FLAG_IGNORE_REVOCATION 0x00000080
  929. #define SECURITY_FLAG_IGNORE_UNKNOWN_CA 0x00000100
  930. #define SECURITY_FLAG_IGNORE_WRONG_USAGE 0x00000200
  931. #define SECURITY_FLAG_IGNORE_CERT_CN_INVALID INTERNET_FLAG_IGNORE_CERT_CN_INVALID
  932. #define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
  933. #define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
  934. #define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
  935. #define SECURITY_SET_MASK (SECURITY_FLAG_IGNORE_REVOCATION |\
  936. SECURITY_FLAG_IGNORE_UNKNOWN_CA |\
  937. SECURITY_FLAG_IGNORE_CERT_CN_INVALID |\
  938. SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |\
  939. SECURITY_FLAG_IGNORE_WRONG_USAGE)
  940. // valid autodial modes
  941. #define AUTODIAL_MODE_NEVER 1
  942. #define AUTODIAL_MODE_ALWAYS 2
  943. #define AUTODIAL_MODE_NO_NETWORK_PRESENT 4
  944. BOOLAPI
  945. InternetGetLastResponseInfo(
  946. OUT LPDWORD lpdwError,
  947. OUT LPWSTR lpszBuffer OPTIONAL,
  948. IN OUT LPDWORD lpdwBufferLength
  949. );
  950. #ifdef UNICODE
  951. #define InternetGetLastResponseInfo InternetGetLastResponseInfoW
  952. #endif // !UNICODE
  953. //
  954. // callback function for WinHttpSetStatusCallback
  955. //
  956. typedef
  957. VOID
  958. (CALLBACK * INTERNET_STATUS_CALLBACK)(
  959. IN HINTERNET hInternet,
  960. IN DWORD_PTR dwContext,
  961. IN DWORD dwInternetStatus,
  962. IN LPVOID lpvStatusInformation OPTIONAL,
  963. IN DWORD dwStatusInformationLength
  964. );
  965. typedef INTERNET_STATUS_CALLBACK * LPINTERNET_STATUS_CALLBACK;
  966. INTERNETAPI
  967. INTERNET_STATUS_CALLBACK
  968. WINAPI
  969. WinHttpSetStatusCallback(
  970. IN HINTERNET hInternet,
  971. IN INTERNET_STATUS_CALLBACK lpfnInternetCallback,
  972. IN DWORD dwNotificationFlags,
  973. IN DWORD_PTR dwReserved
  974. );
  975. //
  976. // status manifests for WinHttp status callback
  977. //
  978. #define INTERNET_STATUS_RESOLVING_NAME 0x00000001
  979. #define INTERNET_STATUS_NAME_RESOLVED 0x00000002
  980. #define INTERNET_STATUS_CONNECTING_TO_SERVER 0x00000004
  981. #define INTERNET_STATUS_CONNECTED_TO_SERVER 0x00000008
  982. #define INTERNET_STATUS_SENDING_REQUEST 0x00000010
  983. #define INTERNET_STATUS_REQUEST_SENT 0x00000020
  984. #define INTERNET_STATUS_RECEIVING_RESPONSE 0x00000040
  985. #define INTERNET_STATUS_RESPONSE_RECEIVED 0x00000080
  986. #define INTERNET_STATUS_CLOSING_CONNECTION 0x00000100
  987. #define INTERNET_STATUS_CONNECTION_CLOSED 0x00000200
  988. #define INTERNET_STATUS_HANDLE_CREATED 0x00000400
  989. #define INTERNET_STATUS_HANDLE_CLOSING 0x00000800
  990. #define INTERNET_STATUS_DETECTING_PROXY 0x00001000
  991. #define INTERNET_STATUS_REQUEST_COMPLETE 0x00002000
  992. #define INTERNET_STATUS_REDIRECT 0x00004000
  993. #define INTERNET_STATUS_INTERMEDIATE_RESPONSE 0x00008000
  994. #define WINHTTP_CALLBACK_FLAG_RESOLVE_NAME (INTERNET_STATUS_RESOLVING_NAME | INTERNET_STATUS_NAME_RESOLVED)
  995. #define WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER (INTERNET_STATUS_CONNECTING_TO_SERVER | INTERNET_STATUS_CONNECTED_TO_SERVER)
  996. #define WINHTTP_CALLBACK_FLAG_SEND_REQUEST (INTERNET_STATUS_SENDING_REQUEST | INTERNET_STATUS_REQUEST_SENT)
  997. #define WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE (INTERNET_STATUS_RECEIVING_RESPONSE | INTERNET_STATUS_RESPONSE_RECEIVED)
  998. #define WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION (INTERNET_STATUS_CLOSING_CONNECTION | INTERNET_STATUS_CONNECTION_CLOSED)
  999. #define WINHTTP_CALLBACK_FLAG_HANDLES (INTERNET_STATUS_HANDLE_CREATED | INTERNET_STATUS_HANDLE_CLOSING)
  1000. #define WINHTTP_CALLBACK_FLAG_DETECTING_PROXY INTERNET_STATUS_DETECTING_PROXY
  1001. #define WINHTTP_CALLBACK_FLAG_REQUEST_COMPLETE INTERNET_STATUS_REQUEST_COMPLETE
  1002. #define WINHTTP_CALLBACK_FLAG_REDIRECT INTERNET_STATUS_REDIRECT
  1003. #define WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE INTERNET_STATUS_INTERMEDIATE_RESPONSE
  1004. ;begin_internal
  1005. //ensure that WINHTTP_CALLBACK_FLAG_ALL always matches OR of all the CALLBACKFLAGS
  1006. ;end_internal
  1007. #define WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS 0xffffffff
  1008. //
  1009. // the following can be indicated in a state change notification:
  1010. //
  1011. #define INTERNET_STATE_CONNECTED 0x00000001 // connected state (mutually exclusive with disconnected)
  1012. #define INTERNET_STATE_DISCONNECTED 0x00000002 // disconnected from network
  1013. #define INTERNET_STATE_DISCONNECTED_BY_USER 0x00000010 // disconnected by user request
  1014. #define INTERNET_STATE_IDLE 0x00000100 // no network requests being made (by Wininet)
  1015. #define INTERNET_STATE_BUSY 0x00000200 // network requests being made (by Wininet)
  1016. ;begin_internal
  1017. #define INTERNET_STATE_ONLINE INTERNET_STATE_CONNECTED
  1018. #define INTERNET_STATE_OFFLINE INTERNET_STATE_DISCONNECTED
  1019. #define INTERNET_STATE_OFFLINE_USER INTERNET_STATE_DISCONNECTED_BY_USER
  1020. #define INTERNET_LINE_STATE_MASK (INTERNET_STATE_ONLINE | INTERNET_STATE_OFFLINE)
  1021. #define INTERNET_BUSY_STATE_MASK (INTERNET_STATE_IDLE | INTERNET_STATE_BUSY)
  1022. ;end_internal
  1023. //
  1024. // if the following value is returned by WinHttpSetStatusCallback, then
  1025. // probably an invalid (non-code) address was supplied for the callback
  1026. //
  1027. #define INTERNET_INVALID_STATUS_CALLBACK ((INTERNET_STATUS_CALLBACK)(-1L))
  1028. //
  1029. // HTTP
  1030. //
  1031. //
  1032. // manifests
  1033. //
  1034. //
  1035. // the default major/minor HTTP version numbers
  1036. //
  1037. #define HTTP_MAJOR_VERSION 1
  1038. #define HTTP_MINOR_VERSION 0
  1039. #define HTTP_VERSIONW L"HTTP/1.0"
  1040. #ifdef UNICODE
  1041. #define HTTP_VERSION HTTP_VERSIONW
  1042. #endif
  1043. //
  1044. // WinHttpQueryHeaders info levels. Generally, there is one info level
  1045. // for each potential RFC822/HTTP/MIME header that an HTTP server
  1046. // may send as part of a request response.
  1047. //
  1048. // The HTTP_QUERY_RAW_HEADERS info level is provided for clients
  1049. // that choose to perform their own header parsing.
  1050. //
  1051. ;begin_internal
  1052. //
  1053. // Note that adding any HTTP_QUERY_* codes here must be followed
  1054. // by an equivlent line in wininet\http\hashgen\hashgen.cpp
  1055. // please see that file for further information regarding
  1056. // the addition of new HTTP headers
  1057. //
  1058. ;end_internal
  1059. #define HTTP_QUERY_MIME_VERSION 0
  1060. #define HTTP_QUERY_CONTENT_TYPE 1
  1061. #define HTTP_QUERY_CONTENT_TRANSFER_ENCODING 2
  1062. #define HTTP_QUERY_CONTENT_ID 3
  1063. #define HTTP_QUERY_CONTENT_DESCRIPTION 4
  1064. #define HTTP_QUERY_CONTENT_LENGTH 5
  1065. #define HTTP_QUERY_CONTENT_LANGUAGE 6
  1066. #define HTTP_QUERY_ALLOW 7
  1067. #define HTTP_QUERY_PUBLIC 8
  1068. #define HTTP_QUERY_DATE 9
  1069. #define HTTP_QUERY_EXPIRES 10
  1070. #define HTTP_QUERY_LAST_MODIFIED 11
  1071. #define HTTP_QUERY_MESSAGE_ID 12
  1072. #define HTTP_QUERY_URI 13
  1073. #define HTTP_QUERY_DERIVED_FROM 14
  1074. #define HTTP_QUERY_COST 15
  1075. #define HTTP_QUERY_LINK 16
  1076. #define HTTP_QUERY_PRAGMA 17
  1077. #define HTTP_QUERY_VERSION 18 // special: part of status line
  1078. #define HTTP_QUERY_STATUS_CODE 19 // special: part of status line
  1079. #define HTTP_QUERY_STATUS_TEXT 20 // special: part of status line
  1080. #define HTTP_QUERY_RAW_HEADERS 21 // special: all headers as ASCIIZ
  1081. #define HTTP_QUERY_RAW_HEADERS_CRLF 22 // special: all headers
  1082. #define HTTP_QUERY_CONNECTION 23
  1083. #define HTTP_QUERY_ACCEPT 24
  1084. #define HTTP_QUERY_ACCEPT_CHARSET 25
  1085. #define HTTP_QUERY_ACCEPT_ENCODING 26
  1086. #define HTTP_QUERY_ACCEPT_LANGUAGE 27
  1087. #define HTTP_QUERY_AUTHORIZATION 28
  1088. #define HTTP_QUERY_CONTENT_ENCODING 29
  1089. #define HTTP_QUERY_FORWARDED 30
  1090. #define HTTP_QUERY_FROM 31
  1091. #define HTTP_QUERY_IF_MODIFIED_SINCE 32
  1092. #define HTTP_QUERY_LOCATION 33
  1093. #define HTTP_QUERY_ORIG_URI 34
  1094. #define HTTP_QUERY_REFERER 35
  1095. #define HTTP_QUERY_RETRY_AFTER 36
  1096. #define HTTP_QUERY_SERVER 37
  1097. #define HTTP_QUERY_TITLE 38
  1098. #define HTTP_QUERY_USER_AGENT 39
  1099. #define HTTP_QUERY_WWW_AUTHENTICATE 40
  1100. #define HTTP_QUERY_PROXY_AUTHENTICATE 41
  1101. #define HTTP_QUERY_ACCEPT_RANGES 42
  1102. #define HTTP_QUERY_SET_COOKIE 43
  1103. #define HTTP_QUERY_COOKIE 44
  1104. #define HTTP_QUERY_REQUEST_METHOD 45 // special: GET/POST etc.
  1105. #define HTTP_QUERY_REFRESH 46
  1106. #define HTTP_QUERY_CONTENT_DISPOSITION 47
  1107. //
  1108. // HTTP 1.1 defined headers
  1109. //
  1110. #define HTTP_QUERY_AGE 48
  1111. #define HTTP_QUERY_CACHE_CONTROL 49
  1112. #define HTTP_QUERY_CONTENT_BASE 50
  1113. #define HTTP_QUERY_CONTENT_LOCATION 51
  1114. #define HTTP_QUERY_CONTENT_MD5 52
  1115. #define HTTP_QUERY_CONTENT_RANGE 53
  1116. #define HTTP_QUERY_ETAG 54
  1117. #define HTTP_QUERY_HOST 55
  1118. #define HTTP_QUERY_IF_MATCH 56
  1119. #define HTTP_QUERY_IF_NONE_MATCH 57
  1120. #define HTTP_QUERY_IF_RANGE 58
  1121. #define HTTP_QUERY_IF_UNMODIFIED_SINCE 59
  1122. #define HTTP_QUERY_MAX_FORWARDS 60
  1123. #define HTTP_QUERY_PROXY_AUTHORIZATION 61
  1124. #define HTTP_QUERY_RANGE 62
  1125. #define HTTP_QUERY_TRANSFER_ENCODING 63
  1126. #define HTTP_QUERY_UPGRADE 64
  1127. #define HTTP_QUERY_VARY 65
  1128. #define HTTP_QUERY_VIA 66
  1129. #define HTTP_QUERY_WARNING 67
  1130. #define HTTP_QUERY_EXPECT 68
  1131. #define HTTP_QUERY_PROXY_CONNECTION 69
  1132. #define HTTP_QUERY_UNLESS_MODIFIED_SINCE 70
  1133. ;begin_internal
  1134. // These are not part of HTTP 1.1 yet. We will propose these to the
  1135. // HTTP extensions working group. These are required for the client-caps support
  1136. // we are doing in conjuntion with IIS.
  1137. ;end_internal
  1138. #define HTTP_QUERY_ECHO_REQUEST 71
  1139. #define HTTP_QUERY_ECHO_REPLY 72
  1140. // These are the set of headers that should be added back to a request when
  1141. // re-doing a request after a RETRY_WITH response.
  1142. #define HTTP_QUERY_ECHO_HEADERS 73
  1143. #define HTTP_QUERY_ECHO_HEADERS_CRLF 74
  1144. #define HTTP_QUERY_PROXY_SUPPORT 75
  1145. #define HTTP_QUERY_AUTHENTICATION_INFO 76
  1146. #define HTTP_QUERY_MAX 76
  1147. //
  1148. // HTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel
  1149. // parameter of WinHttpQueryHeaders() then the lpBuffer parameter contains the name
  1150. // of the header we are to query
  1151. //
  1152. #define HTTP_QUERY_CUSTOM 65535
  1153. //
  1154. // HTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel
  1155. // parameter of WinHttpQueryHeaders() then the request headers will be queried for the
  1156. // request information
  1157. //
  1158. #define HTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000
  1159. //
  1160. // HTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter
  1161. // of WinHttpQueryHeaders() AND the header being queried contains date information,
  1162. // e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure
  1163. // containing the date and time information converted from the header string
  1164. //
  1165. #define HTTP_QUERY_FLAG_SYSTEMTIME 0x40000000
  1166. //
  1167. // HTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of
  1168. // HttpQueryHeader(), then the value of the header will be converted to a number
  1169. // before being returned to the caller, if applicable
  1170. //
  1171. #define HTTP_QUERY_FLAG_NUMBER 0x20000000
  1172. //
  1173. // HTTP_QUERY_FLAG_COALESCE - combine the values from several headers of the
  1174. // same name into the output buffer
  1175. //
  1176. #define HTTP_QUERY_FLAG_COALESCE 0x10000000
  1177. #define HTTP_QUERY_MODIFIER_FLAGS_MASK (HTTP_QUERY_FLAG_REQUEST_HEADERS \
  1178. | HTTP_QUERY_FLAG_SYSTEMTIME \
  1179. | HTTP_QUERY_FLAG_NUMBER \
  1180. | HTTP_QUERY_FLAG_COALESCE \
  1181. )
  1182. #define HTTP_QUERY_HEADER_MASK (~HTTP_QUERY_MODIFIER_FLAGS_MASK)
  1183. //
  1184. // HTTP Response Status Codes:
  1185. //
  1186. #define HTTP_STATUS_CONTINUE 100 // OK to continue with request
  1187. #define HTTP_STATUS_SWITCH_PROTOCOLS 101 // server has switched protocols in upgrade header
  1188. #define HTTP_STATUS_OK 200 // request completed
  1189. #define HTTP_STATUS_CREATED 201 // object created, reason = new URI
  1190. #define HTTP_STATUS_ACCEPTED 202 // async completion (TBS)
  1191. #define HTTP_STATUS_PARTIAL 203 // partial completion
  1192. #define HTTP_STATUS_NO_CONTENT 204 // no info to return
  1193. #define HTTP_STATUS_RESET_CONTENT 205 // request completed, but clear form
  1194. #define HTTP_STATUS_PARTIAL_CONTENT 206 // partial GET furfilled
  1195. #define HTTP_STATUS_AMBIGUOUS 300 // server couldn't decide what to return
  1196. #define HTTP_STATUS_MOVED 301 // object permanently moved
  1197. #define HTTP_STATUS_REDIRECT 302 // object temporarily moved
  1198. #define HTTP_STATUS_REDIRECT_METHOD 303 // redirection w/ new access method
  1199. #define HTTP_STATUS_NOT_MODIFIED 304 // if-modified-since was not modified
  1200. #define HTTP_STATUS_USE_PROXY 305 // redirection to proxy, location header specifies proxy to use
  1201. #define HTTP_STATUS_REDIRECT_KEEP_VERB 307 // HTTP/1.1: keep same verb
  1202. #define HTTP_STATUS_BAD_REQUEST 400 // invalid syntax
  1203. #define HTTP_STATUS_DENIED 401 // access denied
  1204. #define HTTP_STATUS_PAYMENT_REQ 402 // payment required
  1205. #define HTTP_STATUS_FORBIDDEN 403 // request forbidden
  1206. #define HTTP_STATUS_NOT_FOUND 404 // object not found
  1207. #define HTTP_STATUS_BAD_METHOD 405 // method is not allowed
  1208. #define HTTP_STATUS_NONE_ACCEPTABLE 406 // no response acceptable to client found
  1209. #define HTTP_STATUS_PROXY_AUTH_REQ 407 // proxy authentication required
  1210. #define HTTP_STATUS_REQUEST_TIMEOUT 408 // server timed out waiting for request
  1211. #define HTTP_STATUS_CONFLICT 409 // user should resubmit with more info
  1212. #define HTTP_STATUS_GONE 410 // the resource is no longer available
  1213. #define HTTP_STATUS_LENGTH_REQUIRED 411 // the server refused to accept request w/o a length
  1214. #define HTTP_STATUS_PRECOND_FAILED 412 // precondition given in request failed
  1215. #define HTTP_STATUS_REQUEST_TOO_LARGE 413 // request entity was too large
  1216. #define HTTP_STATUS_URI_TOO_LONG 414 // request URI too long
  1217. #define HTTP_STATUS_UNSUPPORTED_MEDIA 415 // unsupported media type
  1218. #define HTTP_STATUS_RETRY_WITH 449 // retry after doing the appropriate action.
  1219. #define HTTP_STATUS_SERVER_ERROR 500 // internal server error
  1220. #define HTTP_STATUS_NOT_SUPPORTED 501 // required not supported
  1221. #define HTTP_STATUS_BAD_GATEWAY 502 // error response received from gateway
  1222. #define HTTP_STATUS_SERVICE_UNAVAIL 503 // temporarily overloaded
  1223. #define HTTP_STATUS_GATEWAY_TIMEOUT 504 // timed out waiting for gateway
  1224. #define HTTP_STATUS_VERSION_NOT_SUP 505 // HTTP version not supported
  1225. #define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE
  1226. #define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP
  1227. //
  1228. // prototypes
  1229. //
  1230. INTERNETAPI
  1231. HINTERNET
  1232. WINAPI
  1233. WinHttpOpenRequest(
  1234. IN HINTERNET hConnect,
  1235. IN LPCWSTR lpszVerb,
  1236. IN LPCWSTR lpszObjectName,
  1237. IN LPCWSTR lpszVersion,
  1238. IN LPCWSTR lpszReferrer OPTIONAL,
  1239. IN LPCWSTR FAR * lplpszAcceptTypes OPTIONAL,
  1240. IN DWORD dwFlags,
  1241. IN DWORD_PTR dwContext
  1242. );
  1243. BOOLAPI
  1244. WinHttpAddRequestHeaders(
  1245. IN HINTERNET hRequest,
  1246. IN LPCWSTR lpszHeaders,
  1247. IN DWORD dwHeadersLength,
  1248. IN DWORD dwModifiers
  1249. );
  1250. //
  1251. // values for dwModifiers parameter of HttpAddRequestHeaders()
  1252. //
  1253. #define HTTP_ADDREQ_INDEX_MASK 0x0000FFFF
  1254. #define HTTP_ADDREQ_FLAGS_MASK 0xFFFF0000
  1255. //
  1256. // HTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't
  1257. // already exist
  1258. //
  1259. #define HTTP_ADDREQ_FLAG_ADD_IF_NEW 0x10000000
  1260. //
  1261. // HTTP_ADDREQ_FLAG_ADD - if HTTP_ADDREQ_FLAG_REPLACE is set but the header is
  1262. // not found then if this flag is set, the header is added anyway, so long as
  1263. // there is a valid header-value
  1264. //
  1265. #define HTTP_ADDREQ_FLAG_ADD 0x20000000
  1266. //
  1267. // HTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g.
  1268. // "Accept: text/*" and "Accept: audio/*" with this flag results in a single
  1269. // header: "Accept: text/*, audio/*"
  1270. //
  1271. #define HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA 0x40000000
  1272. #define HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON 0x01000000
  1273. #define HTTP_ADDREQ_FLAG_COALESCE HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
  1274. //
  1275. // HTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can
  1276. // be supplied in the buffer. If the header to be replaced is not the first
  1277. // in a list of headers with the same name, then the relative index should be
  1278. // supplied in the low 8 bits of the dwModifiers parameter. If the header-value
  1279. // part is missing, then the header is removed
  1280. //
  1281. #define HTTP_ADDREQ_FLAG_REPLACE 0x80000000
  1282. BOOLAPI
  1283. WinHttpSendRequest(
  1284. IN HINTERNET hRequest,
  1285. IN LPCWSTR lpszHeaders OPTIONAL,
  1286. IN DWORD dwHeadersLength,
  1287. IN LPVOID lpOptional OPTIONAL,
  1288. IN DWORD dwOptionalLength,
  1289. IN DWORD dwTotalLength,
  1290. IN DWORD dwFlags
  1291. );
  1292. BOOLAPI WinHttpSetCredentials (
  1293. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest.
  1294. IN DWORD AuthTargets, // Only WINHTTP_AUTH_TARGET_SERVER and
  1295. // WINHTTP_AUTH_TARGET_PROXY are supported
  1296. // in this version and they are mutually
  1297. // exclusive
  1298. IN DWORD AuthScheme, // must be one of the supported Auth Schemes
  1299. // returned from WinHttpQueryAuthSchemes(), Apps
  1300. // should use the Preferred Scheme returned
  1301. IN LPCWSTR pszUserName, // 1) NULL if default creds is to be used, in
  1302. // which case pszPassword will be ignored
  1303. IN LPCWSTR pszPassword, // 1) "" == Blank Password; 2)Parameter ignored
  1304. // if pszUserName is NULL; 3) Invalid to pass in
  1305. // NULL if pszUserName is not NULL
  1306. IN LPVOID pAuthParams
  1307. );
  1308. BOOLAPI WinHttpQueryAuthSchemes (
  1309. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest
  1310. OUT LPDWORD lpdwSupportedSchemes, // a bitmap of available Authentication Schemes
  1311. OUT LPDWORD lpdwPreferredScheme, // WinHttp's preferred Authentication Method
  1312. OUT LPDWORD pdwAuthTarget
  1313. );
  1314. BOOLAPI WinHttpQueryAuthParams(
  1315. IN HINTERNET hRequest, // HINTERNET handle returned by WinHttpOpenRequest
  1316. IN DWORD AuthScheme,
  1317. OUT LPVOID* pAuthParams // Scheme-specific Advanced auth parameters
  1318. );
  1319. //
  1320. // bogus flags
  1321. //
  1322. #define HSR_ASYNC WININET_API_FLAG_ASYNC // force async
  1323. #define HSR_SYNC WININET_API_FLAG_SYNC // force sync
  1324. #define HSR_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT // use dwContext value
  1325. #define HSR_INITIATE 0x00000008 // iterative operation (completed by HttpEndRequest)
  1326. #define HSR_DOWNLOAD 0x00000010 // download to file
  1327. #define HSR_CHUNKED 0x00000020 // operation is send of chunked data
  1328. INTERNETAPI
  1329. BOOL
  1330. WINAPI
  1331. WinHttpReceiveResponse(
  1332. IN HINTERNET hRequest,
  1333. OUT LPINTERNET_BUFFERSW lpBuffersOut OPTIONAL,
  1334. IN DWORD dwFlags,
  1335. IN DWORD_PTR dwContext
  1336. );
  1337. BOOLAPI
  1338. WinHttpQueryHeaders(
  1339. IN HINTERNET hRequest,
  1340. IN DWORD dwInfoLevel,
  1341. IN OUT LPVOID lpBuffer OPTIONAL,
  1342. IN OUT LPDWORD lpdwBufferLength,
  1343. IN OUT LPDWORD lpdwIndex OPTIONAL
  1344. );
  1345. ;begin_internal
  1346. typedef struct _INTERNET_COOKIE {
  1347. DWORD cbSize;
  1348. LPSTR pszName;
  1349. LPSTR pszData;
  1350. LPSTR pszDomain;
  1351. LPSTR pszPath;
  1352. FILETIME *pftExpires;
  1353. DWORD dwFlags;
  1354. LPSTR pszUrl;
  1355. } INTERNET_COOKIE, *PINTERNET_COOKIE;
  1356. #define INTERNET_COOKIE_IS_SECURE 0x01
  1357. #define INTERNET_COOKIE_IS_SESSION 0x02
  1358. //
  1359. // If SERIALIZE_DIALOGS flag set, client should implement thread-safe non-blocking callback...
  1360. //
  1361. DWORD InternetAuthNotifyCallback
  1362. (
  1363. DWORD_PTR dwContext, // as passed to InternetErrorDlg
  1364. DWORD dwReturn, // error code: success, resend, or cancel
  1365. LPVOID lpReserved // reserved: will be set to null
  1366. );
  1367. typedef DWORD (CALLBACK * PFN_AUTH_NOTIFY) (DWORD_PTR, DWORD, LPVOID);
  1368. //
  1369. // ... and last parameter of InternetErrorDlg should point to...
  1370. //
  1371. typedef struct
  1372. {
  1373. DWORD cbStruct; // size of this structure
  1374. DWORD dwOptions; // reserved: must set to 0
  1375. PFN_AUTH_NOTIFY pfnNotify; // notification callback to retry InternetErrorDlg
  1376. DWORD_PTR dwContext; // context to pass to to notification function
  1377. }
  1378. INTERNET_AUTH_NOTIFY_DATA;
  1379. ;end_internal
  1380. //#if !defined(_WINERROR_)
  1381. //
  1382. // WinHttp API error returns
  1383. //
  1384. #define INTERNET_ERROR_BASE 12000
  1385. #define ERROR_INTERNET_OUT_OF_HANDLES (INTERNET_ERROR_BASE + 1)
  1386. #define ERROR_INTERNET_TIMEOUT (INTERNET_ERROR_BASE + 2)
  1387. #define ERROR_INTERNET_EXTENDED_ERROR (INTERNET_ERROR_BASE + 3)
  1388. #define ERROR_INTERNET_INTERNAL_ERROR (INTERNET_ERROR_BASE + 4)
  1389. #define ERROR_INTERNET_INVALID_URL (INTERNET_ERROR_BASE + 5)
  1390. #define ERROR_INTERNET_UNRECOGNIZED_SCHEME (INTERNET_ERROR_BASE + 6)
  1391. #define ERROR_INTERNET_NAME_NOT_RESOLVED (INTERNET_ERROR_BASE + 7)
  1392. #define ERROR_INTERNET_PROTOCOL_NOT_FOUND (INTERNET_ERROR_BASE + 8)
  1393. #define ERROR_INTERNET_INVALID_OPTION (INTERNET_ERROR_BASE + 9)
  1394. #define ERROR_INTERNET_BAD_OPTION_LENGTH (INTERNET_ERROR_BASE + 10)
  1395. #define ERROR_INTERNET_OPTION_NOT_SETTABLE (INTERNET_ERROR_BASE + 11)
  1396. #define ERROR_INTERNET_SHUTDOWN (INTERNET_ERROR_BASE + 12)
  1397. #define ERROR_INTERNET_INCORRECT_USER_NAME (INTERNET_ERROR_BASE + 13)
  1398. #define ERROR_INTERNET_INCORRECT_PASSWORD (INTERNET_ERROR_BASE + 14)
  1399. #define ERROR_INTERNET_LOGIN_FAILURE (INTERNET_ERROR_BASE + 15)
  1400. #define ERROR_INTERNET_INVALID_OPERATION (INTERNET_ERROR_BASE + 16)
  1401. #define ERROR_INTERNET_OPERATION_CANCELLED (INTERNET_ERROR_BASE + 17)
  1402. #define ERROR_INTERNET_INCORRECT_HANDLE_TYPE (INTERNET_ERROR_BASE + 18)
  1403. #define ERROR_INTERNET_INCORRECT_HANDLE_STATE (INTERNET_ERROR_BASE + 19)
  1404. #define ERROR_INTERNET_NOT_PROXY_REQUEST (INTERNET_ERROR_BASE + 20)
  1405. #define ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND (INTERNET_ERROR_BASE + 21)
  1406. #define ERROR_INTERNET_BAD_REGISTRY_PARAMETER (INTERNET_ERROR_BASE + 22)
  1407. #define ERROR_INTERNET_NO_DIRECT_ACCESS (INTERNET_ERROR_BASE + 23)
  1408. #define ERROR_INTERNET_NO_CONTEXT (INTERNET_ERROR_BASE + 24)
  1409. #define ERROR_INTERNET_NO_CALLBACK (INTERNET_ERROR_BASE + 25)
  1410. #define ERROR_INTERNET_REQUEST_PENDING (INTERNET_ERROR_BASE + 26)
  1411. #define ERROR_INTERNET_INCORRECT_FORMAT (INTERNET_ERROR_BASE + 27)
  1412. #define ERROR_INTERNET_ITEM_NOT_FOUND (INTERNET_ERROR_BASE + 28)
  1413. #define ERROR_INTERNET_CANNOT_CONNECT (INTERNET_ERROR_BASE + 29)
  1414. #define ERROR_INTERNET_CONNECTION_ABORTED (INTERNET_ERROR_BASE + 30)
  1415. #define ERROR_INTERNET_CONNECTION_RESET (INTERNET_ERROR_BASE + 31)
  1416. #define ERROR_INTERNET_FORCE_RETRY (INTERNET_ERROR_BASE + 32)
  1417. #define ERROR_INTERNET_INVALID_PROXY_REQUEST (INTERNET_ERROR_BASE + 33)
  1418. #define ERROR_INTERNET_NEED_UI (INTERNET_ERROR_BASE + 34)
  1419. #define ERROR_INTERNET_HANDLE_EXISTS (INTERNET_ERROR_BASE + 36)
  1420. #define ERROR_INTERNET_SEC_CERT_DATE_INVALID (INTERNET_ERROR_BASE + 37)
  1421. #define ERROR_INTERNET_SEC_CERT_CN_INVALID (INTERNET_ERROR_BASE + 38)
  1422. #define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR (INTERNET_ERROR_BASE + 39)
  1423. #define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR (INTERNET_ERROR_BASE + 40)
  1424. #define ERROR_INTERNET_MIXED_SECURITY (INTERNET_ERROR_BASE + 41)
  1425. #define ERROR_INTERNET_CHG_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 42)
  1426. #define ERROR_INTERNET_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 43)
  1427. #define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED (INTERNET_ERROR_BASE + 44)
  1428. #define ERROR_INTERNET_INVALID_CA (INTERNET_ERROR_BASE + 45)
  1429. #define ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP (INTERNET_ERROR_BASE + 46)
  1430. #define ERROR_INTERNET_ASYNC_THREAD_FAILED (INTERNET_ERROR_BASE + 47)
  1431. #define ERROR_INTERNET_REDIRECT_SCHEME_CHANGE (INTERNET_ERROR_BASE + 48)
  1432. #define ERROR_INTERNET_DIALOG_PENDING (INTERNET_ERROR_BASE + 49)
  1433. #define ERROR_INTERNET_RETRY_DIALOG (INTERNET_ERROR_BASE + 50)
  1434. ;begin_internal
  1435. #define ERROR_INTERNET_NO_NEW_CONTAINERS (INTERNET_ERROR_BASE + 51)
  1436. ;end_internal
  1437. #define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR (INTERNET_ERROR_BASE + 52)
  1438. #define ERROR_INTERNET_INSERT_CDROM (INTERNET_ERROR_BASE + 53)
  1439. #define ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED (INTERNET_ERROR_BASE + 54)
  1440. #define ERROR_INTERNET_SEC_CERT_ERRORS (INTERNET_ERROR_BASE + 55)
  1441. #define ERROR_INTERNET_SEC_CERT_NO_REV (INTERNET_ERROR_BASE + 56)
  1442. #define ERROR_INTERNET_SEC_CERT_REV_FAILED (INTERNET_ERROR_BASE + 57)
  1443. //
  1444. // HTTP API errors
  1445. //
  1446. #define ERROR_HTTP_HEADER_NOT_FOUND (INTERNET_ERROR_BASE + 150)
  1447. #define ERROR_HTTP_DOWNLEVEL_SERVER (INTERNET_ERROR_BASE + 151)
  1448. #define ERROR_HTTP_INVALID_SERVER_RESPONSE (INTERNET_ERROR_BASE + 152)
  1449. #define ERROR_HTTP_INVALID_HEADER (INTERNET_ERROR_BASE + 153)
  1450. #define ERROR_HTTP_INVALID_QUERY_REQUEST (INTERNET_ERROR_BASE + 154)
  1451. #define ERROR_HTTP_HEADER_ALREADY_EXISTS (INTERNET_ERROR_BASE + 155)
  1452. #define ERROR_HTTP_REDIRECT_FAILED (INTERNET_ERROR_BASE + 156)
  1453. #define ERROR_HTTP_NOT_REDIRECTED (INTERNET_ERROR_BASE + 160)
  1454. #define ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 161)
  1455. #define ERROR_HTTP_COOKIE_DECLINED (INTERNET_ERROR_BASE + 162)
  1456. #define ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 168)
  1457. //
  1458. // additional WinHttp API error codes
  1459. //
  1460. #define ERROR_INTERNET_SECURITY_CHANNEL_ERROR (INTERNET_ERROR_BASE + 157)
  1461. #define ERROR_INTERNET_UNABLE_TO_CACHE_FILE (INTERNET_ERROR_BASE + 158)
  1462. #define ERROR_INTERNET_TCPIP_NOT_INSTALLED (INTERNET_ERROR_BASE + 159)
  1463. #define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163)
  1464. #define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164)
  1465. #define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165)
  1466. #define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166)
  1467. #define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167)
  1468. #define ERROR_INTERNET_SEC_INVALID_CERT (INTERNET_ERROR_BASE + 169)
  1469. #define ERROR_INTERNET_SEC_CERT_REVOKED (INTERNET_ERROR_BASE + 170)
  1470. #define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171)
  1471. #define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172)
  1472. #define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173)
  1473. #define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174)
  1474. #define INTERNET_ERROR_LAST ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY
  1475. ;begin_internal
  1476. #define ERROR_INTERNET_OFFLINE ERROR_INTERNET_DISCONNECTED
  1477. //
  1478. // internal error codes that are used to communicate specific information inside
  1479. // of Wininet but which are meaningless at the interface
  1480. //
  1481. #define INTERNET_INTERNAL_ERROR_BASE (INTERNET_ERROR_BASE + 900)
  1482. #define ERROR_INTERNET_INTERNAL_SOCKET_ERROR (INTERNET_INTERNAL_ERROR_BASE + 1)
  1483. #define ERROR_INTERNET_CONNECTION_AVAILABLE (INTERNET_INTERNAL_ERROR_BASE + 2)
  1484. #define ERROR_INTERNET_NO_KNOWN_SERVERS (INTERNET_INTERNAL_ERROR_BASE + 3)
  1485. #define ERROR_INTERNET_PING_FAILED (INTERNET_INTERNAL_ERROR_BASE + 4)
  1486. #define ERROR_INTERNET_NO_PING_SUPPORT (INTERNET_INTERNAL_ERROR_BASE + 5)
  1487. #define ERROR_INTERNET_CACHE_SUCCESS (INTERNET_INTERNAL_ERROR_BASE + 6)
  1488. ;end_internal
  1489. //#endif // !defined(_WINERROR_)
  1490. ;begin_internal
  1491. // Used by security manager.
  1492. INTERNETAPI
  1493. BOOL
  1494. WINAPI
  1495. IsHostInProxyBypassList(
  1496. IN INTERNET_SCHEME tScheme,
  1497. IN LPCSTR lpszHost,
  1498. IN DWORD cchHost);
  1499. ;end_internal
  1500. #define INTERNET_SUPPRESS_RESET_ALL 0x00
  1501. #define INTERNET_SUPPRESS_COOKIE_POLICY 0x01
  1502. #define INTERNET_SUPPRESS_COOKIE_POLICY_RESET 0x02
  1503. ;begin_both
  1504. #if defined(__cplusplus)
  1505. }
  1506. #endif
  1507. ;end_both
  1508. /*
  1509. * Return packing to whatever it was before we
  1510. * entered this file
  1511. */
  1512. #include <poppack.h>
  1513. ;begin_internal
  1514. #endif // !define(_WINHTTPXEX_)
  1515. ;end_internal
  1516. #endif // !defined(_WINHTTPX_)