1/** 2 * Windows API header module 3 * 4 * Translated from Windows SDK Headers 5 * 6 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 * Source: $(DRUNTIMESRC core/sys/windows/_winhttp.d) 8 */ 9module core.sys.windows.winhttp; 10version (Windows): 11@system: 12pragma(lib, "winhttp"); 13// FIXME: Grouping of constants. Windows SDK doesn't make this entirely clear 14// FIXME: Verify WINHTTP_STATUS_CALLBACK function declaration works correctly 15 16import core.sys.windows.w32api; 17import core.sys.windows.winbase; 18import core.sys.windows.windef; 19import core.sys.windows.winsock2; // Selective Imports BUG (: SOCKADDR_STORAGE;) 20 21alias HINTERNET = void*; 22alias LPHINTERNET = HINTERNET*; 23alias INTERNET_PORT = WORD; 24alias LPINTERNET_PORT = INTERNET_PORT*; 25alias INTERNET_SCHEME = int; 26alias LPINTERNET_SCHEME = INTERNET_SCHEME*; 27 28// Protocol 'Manifests' 29enum : DWORD { 30 INTERNET_DEFAULT_PORT = 0, 31 INTERNET_DEFAULT_HTTP_PORT = 80, 32 INTERNET_DEFAULT_HTTPS_PORT = 443 33} 34 35// WinHttpOpen() Flags: 36enum DWORD WINHTTP_FLAG_ASYNC = 0x10000000; 37 38// WinHttpOpenRequest() Flags: 39enum : DWORD { 40 WINHTTP_FLAG_SECURE = 0x00800000, 41 WINHTTP_FLAG_ESCAPE_PERCENT = 0x00000004, 42 WINHTTP_FLAG_NULL_CODEPAGE = 0x00000008, 43 WINHTTP_FLAG_BYPASS_PROXY_CACHE = 0x00000100, 44 WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE, 45 WINHTTP_FLAG_ESCAPE_DISABLE = 0x00000040, 46 WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = 0x00000080, 47 48 SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100, 49 SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000, 50 SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000, 51 SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = 0x00000200 52} 53 54struct WINHTTP_ASYNC_RESULT { 55 DWORD_PTR dwResult; 56 DWORD dwError; 57} 58alias LPWINHTTP_ASYNC_RESULT = WINHTTP_ASYNC_RESULT*; 59 60struct HTTP_VERSION_INFO { 61 DWORD dwMajorVersion; 62 DWORD dwMinorVersion; 63} 64alias LPHTTP_VERSION_INFO = HTTP_VERSION_INFO*; 65 66// URL Scheme 67enum : DWORD { 68 INTERNET_SCHEME_HTTP = 1, 69 INTERNET_SCHEME_HTTPS = 2, 70 INTERNET_SCHEME_FTP = 3, 71 INTERNET_SCHEME_SOCKS = 4 72} 73 74struct URL_COMPONENTS { 75 DWORD dwStructSize; 76 LPWSTR lpszScheme; 77 DWORD dwSchemeLength; 78 INTERNET_SCHEME nScheme; 79 LPWSTR lpszHostName; 80 DWORD dwHostNameLength; 81 INTERNET_PORT nPort; 82 LPWSTR lpszUserName; 83 DWORD dwUserNameLength; 84 LPWSTR lpszPassword; 85 DWORD dwPasswordLength; 86 LPWSTR lpszUrlPath; 87 DWORD dwUrlPathLength; 88 LPWSTR lpszExtraInfo; 89 DWORD dwExtraInfoLength; 90} 91alias LPURL_COMPONENTS = URL_COMPONENTS*; 92alias URL_COMPONENTSW = URL_COMPONENTS; 93alias LPURL_COMPONENTSW = URL_COMPONENTS*; 94 95struct WINHTTP_PROXY_INFO { 96 DWORD dwAccessType; 97 LPWSTR lpszProxy; 98 LPWSTR lpszProxyBypass; 99} 100alias LPWINHTTP_PROXY_INFO = WINHTTP_PROXY_INFO*; 101alias WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO; 102alias LPWINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO*; 103 104struct WINHTTP_AUTOPROXY_OPTIONS { 105 DWORD dwFlags; 106 DWORD dwAutoDetectFlags; 107 LPCWSTR lpszAutoConfigUrl; 108 LPVOID lpvReserved; 109 DWORD dwReserved; 110 BOOL fAutoLogonIfChallenged; 111} 112 113enum : DWORD { 114 WINHTTP_AUTOPROXY_AUTO_DETECT = 0x00000001, 115 WINHTTP_AUTOPROXY_CONFIG_URL = 0x00000002, 116 WINHTTP_AUTOPROXY_HOST_KEEPCASE = 0x00000004, 117 WINHTTP_AUTOPROXY_HOST_LOWERCASE = 0x00000008, 118 WINHTTP_AUTOPROXY_RUN_INPROCESS = 0x00010000, 119 WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY = 0x00020000, 120 WINHTTP_AUTOPROXY_NO_DIRECTACCESS = 0x00040000, 121 WINHTTP_AUTOPROXY_NO_CACHE_CLIENT = 0x00080000, 122 WINHTTP_AUTOPROXY_NO_CACHE_SVC = 0x00100000, 123 124 WINHTTP_AUTOPROXY_SORT_RESULTS = 0x00400000 125} 126 127// dwAutoDetectFlags 128enum : DWORD { 129 WINHTTP_AUTO_DETECT_TYPE_DHCP = 0x00000001, 130 WINHTTP_AUTO_DETECT_TYPE_DNS_A = 0x00000002 131} 132 133struct WINHTTP_CERTIFICATE_INFO { 134 FILETIME ftExpiry; 135 FILETIME ftStart; 136 LPWSTR lpszSubjectInfo; 137 LPWSTR lpszIssuerInfo; 138 LPWSTR lpszProtocolName; 139 LPWSTR lpszSignatureAlgName; 140 LPWSTR lpszEncryptionAlgName; 141 DWORD dwKeySize; 142} 143 144// This structure is only defined #if _WS2DEF_ defined (from <ws2def.h>) - per Windows SDK 145align(4) 146struct WINHTTP_CONNECTION_INFO { 147align(4): 148 DWORD cbSize; 149 version (Win64) 150 DWORD _padding; // cheap trick without the alignment switch over this file 151 SOCKADDR_STORAGE LocalAddress; 152 SOCKADDR_STORAGE RemoteAddress; 153} 154 155// WinHttpTimeFromSystemTime 156enum DWORD WINHTTP_TIME_FORMAT_BUFSIZE = 62; 157 158// CrackUrl, CombineUrl 159enum : DWORD { 160 ICU_NO_ENCODE = 0x20000000, 161 ICU_DECODE = 0x10000000, 162 ICU_NO_META = 0x08000000, 163 ICU_ENCODE_SPACES_ONLY = 0x04000000, 164 ICU_BROWSER_MODE = 0x02000000, 165 ICU_ENCODE_PERCENT = 0x00001000 166} 167// WinHttpCrackUrl, WinHttpCreateUrl 168enum : DWORD { 169 ICU_ESCAPE = 0x80000000, 170 ICU_ESCAPE_AUTHORITY = 0x00002000, 171 ICU_REJECT_USERPWD = 0x00004000 172} 173enum : DWORD { 174 WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0, 175 WINHTTP_ACCESS_TYPE_NO_PROXY = 1, 176 WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3, 177 WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY = 4 178} 179// WinHttpOpen 'prettifiers' 180enum LPCWSTR WINHTTP_NO_PROXY_NAME = null; 181enum LPCWSTR WINHTTP_NO_PROXY_BYPASS = null; 182 183enum LPVOID WINHTTP_NO_CLIENT_CERT_CONTEXT = null; 184 185// WinHttp{Query|Set}Option 186enum : DWORD { 187 WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK, 188 189 WINHTTP_OPTION_CALLBACK = 1, 190 WINHTTP_OPTION_RESOLVE_TIMEOUT = 2, 191 WINHTTP_OPTION_CONNECT_TIMEOUT = 3, 192 WINHTTP_OPTION_CONNECT_RETRIES = 4, 193 WINHTTP_OPTION_SEND_TIMEOUT = 5, 194 WINHTTP_OPTION_RECEIVE_TIMEOUT = 6, 195 WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7, 196 WINHTTP_OPTION_HANDLE_TYPE = 9, 197 WINHTTP_OPTION_READ_BUFFER_SIZE = 12, 198 WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13, 199 WINHTTP_OPTION_PARENT_HANDLE = 21, 200 WINHTTP_OPTION_EXTENDED_ERROR = 24, 201 WINHTTP_OPTION_SECURITY_FLAGS = 31, 202 WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32, 203 WINHTTP_OPTION_URL = 34, 204 WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36, 205 WINHTTP_OPTION_PROXY = 38, 206 WINHTTP_OPTION_PROXY_RESULT_ENTRY = 39, 207 208 WINHTTP_OPTION_USER_AGENT = 41, 209 WINHTTP_OPTION_CONTEXT_VALUE = 45, 210 WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47, 211 WINHTTP_OPTION_REQUEST_PRIORITY = 58, 212 WINHTTP_OPTION_HTTP_VERSION = 59, 213 WINHTTP_OPTION_DISABLE_FEATURE = 63, 214 215 WINHTTP_OPTION_CODEPAGE = 68, 216 WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73, 217 WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74, 218 WINHTTP_OPTION_AUTOLOGON_POLICY = 77, 219 WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78, 220 WINHTTP_OPTION_ENABLE_FEATURE = 79, 221 WINHTTP_OPTION_WORKER_THREAD_COUNT = 80, 222 WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81, 223 WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82, 224 WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83, 225 WINHTTP_OPTION_SECURE_PROTOCOLS = 84, 226 WINHTTP_OPTION_ENABLETRACING = 85, 227 WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86, 228 WINHTTP_OPTION_PASSPORT_RETURN_URL = 87, 229 WINHTTP_OPTION_REDIRECT_POLICY = 88, 230 WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89, 231 WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90, 232 WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91, 233 WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92, 234 WINHTTP_OPTION_CONNECTION_INFO = 93, 235 WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94, 236 WINHTTP_OPTION_SPN = 96, 237 238 WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97, 239 WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98, 240 241 WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99, 242 WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100, 243 WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101, 244 245 WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE = 103, 246 WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE = 104, 247 248 WINHTTP_OPTION_SERVER_SPN_USED = 106, 249 WINHTTP_OPTION_PROXY_SPN_USED = 107, 250 251 WINHTTP_OPTION_SERVER_CBT = 108, 252 253 WINHTTP_OPTION_UNSAFE_HEADER_PARSING = 110, 254 WINHTTP_OPTION_ASSURED_NON_BLOCKING_CALLBACKS = 111, 255 256 WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET = 114, 257 WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT = 115, 258 WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL = 116, 259 260 WINHTTP_OPTION_DECOMPRESSION = 118, 261 262 WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE = 122, 263 WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE = 123, 264 265 //WINHTTP_LAST_OPTION => Moved outside of enum - static if () constraints within enums 266 267 WINHTTP_OPTION_USERNAME = 0x1000, 268 WINHTTP_OPTION_PASSWORD = 0x1001, 269 WINHTTP_OPTION_PROXY_USERNAME = 0x1002, 270 WINHTTP_OPTION_PROXY_PASSWORD = 0x1003, 271 272 WINHTTP_CONNS_PER_SERVER_UNLIMITED = 0xFFFFFFFF, 273 274 WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0, 275 WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1, 276 WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2, 277 278 WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM, 279 280 WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0, 281 WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1, 282 WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2, 283 284 WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS, 285 WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP, 286 287 WINHTTP_DISABLE_PASSPORT_AUTH = 0x00000000, 288 WINHTTP_ENABLE_PASSPORT_AUTH = 0x10000000, 289 WINHTTP_DISABLE_PASSPORT_KEYRING = 0x20000000, 290 WINHTTP_ENABLE_PASSPORT_KEYRING = 0x40000000, 291 292 WINHTTP_DISABLE_COOKIES = 0x00000001, 293 WINHTTP_DISABLE_REDIRECTS = 0x00000002, 294 WINHTTP_DISABLE_AUTHENTICATION = 0x00000004, 295 WINHTTP_DISABLE_KEEP_ALIVE = 0x00000008, 296 297 WINHTTP_ENABLE_SSL_REVOCATION = 0x00000001, 298 WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = 0x00000002, 299 300 WINHTTP_DISABLE_SPN_SERVER_PORT = 0x00000000, 301 WINHTTP_ENABLE_SPN_SERVER_PORT = 0x00000001, 302 WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT 303} 304 305// Windows 8.1 SDK: 306static if (_WIN32_WINNT >= 0x602) { 307 enum DWORD WINHTTP_LAST_OPTION = WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE; 308} else { // Windows 7.0A SDK: 309 enum DWORD WINHTTP_LAST_OPTION = WINHTTP_OPTION_SERVER_CBT; 310} 311 312enum : DWORD { 313 WINHTTP_DECOMPRESSION_FLAG_GZIP = 0x00000001, 314 WINHTTP_DECOMPRESSION_FLAG_DEFLATE = 0x00000002, 315 WINHTTP_DECOMPRESSION_FLAG_ALL = (WINHTTP_DECOMPRESSION_FLAG_GZIP | WINHTTP_DECOMPRESSION_FLAG_DEFLATE) 316} 317 318struct WINHTTP_CREDS { 319 LPSTR lpszUserName; 320 LPSTR lpszPassword; 321 LPSTR lpszRealm; 322 DWORD dwAuthScheme; 323 LPSTR lpszHostName; 324 DWORD dwPort; 325} 326alias PWINHTTP_CREDS = WINHTTP_CREDS*; 327 328struct WINHTTP_CREDS_EX { 329 LPSTR lpszUserName; 330 LPSTR lpszPassword; 331 LPSTR lpszRealm; 332 DWORD dwAuthScheme; 333 LPSTR lpszHostName; 334 DWORD dwPort; 335 LPSTR lpszUrl; 336} 337alias PWINHTTP_CREDS_EX = WINHTTP_CREDS_EX*; 338 339enum : DWORD { 340 WINHTTP_HANDLE_TYPE_SESSION = 1, 341 WINHTTP_HANDLE_TYPE_CONNECT = 2, 342 WINHTTP_HANDLE_TYPE_REQUEST = 3, 343 344 WINHTTP_AUTH_SCHEME_BASIC = 0x00000001, 345 WINHTTP_AUTH_SCHEME_NTLM = 0x00000002, 346 WINHTTP_AUTH_SCHEME_PASSPORT = 0x00000004, 347 WINHTTP_AUTH_SCHEME_DIGEST = 0x00000008, 348 WINHTTP_AUTH_SCHEME_NEGOTIATE = 0x00000010, 349 350 WINHTTP_AUTH_TARGET_SERVER = 0x00000000, 351 WINHTTP_AUTH_TARGET_PROXY = 0x00000001, 352 353 SECURITY_FLAG_SECURE = 0x00000001, 354 SECURITY_FLAG_STRENGTH_WEAK = 0x10000000, 355 SECURITY_FLAG_STRENGTH_MEDIUM = 0x40000000, 356 SECURITY_FLAG_STRENGTH_STRONG = 0x20000000, 357 358 WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = 0x00000001, 359 WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = 0x00000002, 360 WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = 0x00000004, 361 WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = 0x00000008, 362 WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = 0x00000010, 363 WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = 0x00000020, 364 WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = 0x00000040, 365 WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = 0x80000000, 366 367 WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = 0x00000008, 368 WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = 0x00000020, 369 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = 0x00000080, 370 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 = 0x00000200, 371 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 = 0x00000800, 372 WINHTTP_FLAG_SECURE_PROTOCOL_ALL = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 | 373 WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | 374 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1) 375} 376 377alias extern(Windows) int fnWINHTTP_STATUS_CALLBACK(HINTERNET hInternet, DWORD_PTR dwContext, 378 DWORD dwInternetStatus, LPVOID lpvStatusInformation,DWORD dwStatusInformationLength); 379alias WINHTTP_STATUS_CALLBACK = fnWINHTTP_STATUS_CALLBACK*; 380alias LPWINHTTP_STATUS_CALLBACK = WINHTTP_STATUS_CALLBACK*; 381 382enum : DWORD { 383 WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = 0x00000001, 384 WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = 0x00000002, 385 WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = 0x00000004, 386 WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = 0x00000008, 387 WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = 0x00000010, 388 WINHTTP_CALLBACK_STATUS_REQUEST_SENT = 0x00000020, 389 WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = 0x00000040, 390 WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = 0x00000080, 391 WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = 0x00000100, 392 WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = 0x00000200, 393 WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = 0x00000400, 394 WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = 0x00000800, 395 WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = 0x00001000, 396 WINHTTP_CALLBACK_STATUS_REDIRECT = 0x00004000, 397 WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = 0x00008000, 398 WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = 0x00010000, 399 WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE = 0x00020000, 400 WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE = 0x00040000, 401 WINHTTP_CALLBACK_STATUS_READ_COMPLETE = 0x00080000, 402 WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE = 0x00100000, 403 WINHTTP_CALLBACK_STATUS_REQUEST_ERROR = 0x00200000, 404 WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE = 0x00400000 405} 406 407enum : DWORD { 408 WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE = 0x01000000, 409 WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE = 0x02000000, 410 WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE = 0x04000000 411} 412 413enum : DWORD { 414 API_RECEIVE_RESPONSE = 1, 415 API_QUERY_DATA_AVAILABLE = 2, 416 API_READ_DATA = 3, 417 API_WRITE_DATA = 4, 418 API_SEND_REQUEST = 5 419} 420 421enum : DWORD { 422 WINHTTP_CALLBACK_FLAG_RESOLVE_NAME = (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED), 423 WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER = (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER), 424 WINHTTP_CALLBACK_FLAG_SEND_REQUEST = (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT), 425 WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE = (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED), 426 WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION = (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED), 427 WINHTTP_CALLBACK_FLAG_HANDLES = (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING), 428 WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY, 429 WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT, 430 WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE, 431 WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, 432 WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, 433 WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, 434 WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, 435 WINHTTP_CALLBACK_FLAG_READ_COMPLETE = WINHTTP_CALLBACK_STATUS_READ_COMPLETE, 436 WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, 437 WINHTTP_CALLBACK_FLAG_REQUEST_ERROR = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR 438} 439 440enum DWORD WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE = WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE; 441 442// Windows 8+/2012+ 443static if (_WIN32_WINNT >= 0x602) { 444 enum DWORD WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS = (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE 445 | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE 446 | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE 447 | WINHTTP_CALLBACK_STATUS_READ_COMPLETE 448 | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE 449 | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR); 450} else { 451 enum DWORD WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS = (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE 452 | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE 453 | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE 454 | WINHTTP_CALLBACK_STATUS_READ_COMPLETE 455 | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE 456 | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR 457 | WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE); 458} 459 460enum DWORD WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = 0xffffffff; 461 462enum WINHTTP_INVALID_STATUS_CALLBACK = (cast(WINHTTP_STATUS_CALLBACK)(-1L)); 463 464enum : DWORD { 465 WINHTTP_QUERY_MIME_VERSION = 0, 466 WINHTTP_QUERY_CONTENT_TYPE = 1, 467 WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2, 468 WINHTTP_QUERY_CONTENT_ID = 3, 469 WINHTTP_QUERY_CONTENT_DESCRIPTION = 4, 470 WINHTTP_QUERY_CONTENT_LENGTH = 5, 471 WINHTTP_QUERY_CONTENT_LANGUAGE = 6, 472 WINHTTP_QUERY_ALLOW = 7, 473 WINHTTP_QUERY_PUBLIC = 8, 474 WINHTTP_QUERY_DATE = 9, 475 WINHTTP_QUERY_EXPIRES = 10, 476 WINHTTP_QUERY_LAST_MODIFIED = 11, 477 WINHTTP_QUERY_MESSAGE_ID = 12, 478 WINHTTP_QUERY_URI = 13, 479 WINHTTP_QUERY_DERIVED_FROM = 14, 480 WINHTTP_QUERY_COST = 15, 481 WINHTTP_QUERY_LINK = 16, 482 WINHTTP_QUERY_PRAGMA = 17, 483 WINHTTP_QUERY_VERSION = 18, 484 WINHTTP_QUERY_STATUS_CODE = 19, 485 WINHTTP_QUERY_STATUS_TEXT = 20, 486 WINHTTP_QUERY_RAW_HEADERS = 21, 487 WINHTTP_QUERY_RAW_HEADERS_CRLF = 22, 488 WINHTTP_QUERY_CONNECTION = 23, 489 WINHTTP_QUERY_ACCEPT = 24, 490 WINHTTP_QUERY_ACCEPT_CHARSET = 25, 491 WINHTTP_QUERY_ACCEPT_ENCODING = 26, 492 WINHTTP_QUERY_ACCEPT_LANGUAGE = 27, 493 WINHTTP_QUERY_AUTHORIZATION = 28, 494 WINHTTP_QUERY_CONTENT_ENCODING = 29, 495 WINHTTP_QUERY_FORWARDED = 30, 496 WINHTTP_QUERY_FROM = 31, 497 WINHTTP_QUERY_IF_MODIFIED_SINCE = 32, 498 WINHTTP_QUERY_LOCATION = 33, 499 WINHTTP_QUERY_ORIG_URI = 34, 500 WINHTTP_QUERY_REFERER = 35, 501 WINHTTP_QUERY_RETRY_AFTER = 36, 502 WINHTTP_QUERY_SERVER = 37, 503 WINHTTP_QUERY_TITLE = 38, 504 WINHTTP_QUERY_USER_AGENT = 39, 505 WINHTTP_QUERY_WWW_AUTHENTICATE = 40, 506 WINHTTP_QUERY_PROXY_AUTHENTICATE = 41, 507 WINHTTP_QUERY_ACCEPT_RANGES = 42, 508 WINHTTP_QUERY_SET_COOKIE = 43, 509 WINHTTP_QUERY_COOKIE = 44, 510 WINHTTP_QUERY_REQUEST_METHOD = 45, 511 WINHTTP_QUERY_REFRESH = 46, 512 WINHTTP_QUERY_CONTENT_DISPOSITION = 47, 513 514 // HTTP 1.1 defined headers 515 516 WINHTTP_QUERY_AGE = 48, 517 WINHTTP_QUERY_CACHE_CONTROL = 49, 518 WINHTTP_QUERY_CONTENT_BASE = 50, 519 WINHTTP_QUERY_CONTENT_LOCATION = 51, 520 WINHTTP_QUERY_CONTENT_MD5 = 52, 521 WINHTTP_QUERY_CONTENT_RANGE = 53, 522 WINHTTP_QUERY_ETAG = 54, 523 WINHTTP_QUERY_HOST = 55, 524 WINHTTP_QUERY_IF_MATCH = 56, 525 WINHTTP_QUERY_IF_NONE_MATCH = 57, 526 WINHTTP_QUERY_IF_RANGE = 58, 527 WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59, 528 WINHTTP_QUERY_MAX_FORWARDS = 60, 529 WINHTTP_QUERY_PROXY_AUTHORIZATION = 61, 530 WINHTTP_QUERY_RANGE = 62, 531 WINHTTP_QUERY_TRANSFER_ENCODING = 63, 532 WINHTTP_QUERY_UPGRADE = 64, 533 WINHTTP_QUERY_VARY = 65, 534 WINHTTP_QUERY_VIA = 66, 535 WINHTTP_QUERY_WARNING = 67, 536 WINHTTP_QUERY_EXPECT = 68, 537 WINHTTP_QUERY_PROXY_CONNECTION = 69, 538 WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70, 539 540 WINHTTP_QUERY_PROXY_SUPPORT = 75, 541 WINHTTP_QUERY_AUTHENTICATION_INFO = 76, 542 WINHTTP_QUERY_PASSPORT_URLS = 77, 543 WINHTTP_QUERY_PASSPORT_CONFIG = 78, 544 545 WINHTTP_QUERY_MAX = 78, 546 547 WINHTTP_QUERY_CUSTOM = 65535, 548 549 WINHTTP_QUERY_FLAG_REQUEST_HEADERS = 0x80000000, 550 551 WINHTTP_QUERY_FLAG_SYSTEMTIME = 0x40000000, 552 553 WINHTTP_QUERY_FLAG_NUMBER = 0x20000000 554} 555 556enum : DWORD { 557 HTTP_STATUS_CONTINUE = 100, 558 HTTP_STATUS_SWITCH_PROTOCOLS = 101, 559 560 HTTP_STATUS_OK = 200, 561 HTTP_STATUS_CREATED = 201, 562 HTTP_STATUS_ACCEPTED = 202, 563 HTTP_STATUS_PARTIAL = 203, 564 HTTP_STATUS_NO_CONTENT = 204, 565 HTTP_STATUS_RESET_CONTENT = 205, 566 HTTP_STATUS_PARTIAL_CONTENT = 206, 567 HTTP_STATUS_WEBDAV_MULTI_STATUS = 207, 568 569 HTTP_STATUS_AMBIGUOUS = 300, 570 HTTP_STATUS_MOVED = 301, 571 HTTP_STATUS_REDIRECT = 302, 572 HTTP_STATUS_REDIRECT_METHOD = 303, 573 HTTP_STATUS_NOT_MODIFIED = 304, 574 HTTP_STATUS_USE_PROXY = 305, 575 HTTP_STATUS_REDIRECT_KEEP_VERB = 307, 576 577 HTTP_STATUS_BAD_REQUEST = 400, 578 HTTP_STATUS_DENIED = 401, 579 HTTP_STATUS_PAYMENT_REQ = 402, 580 HTTP_STATUS_FORBIDDEN = 403, 581 HTTP_STATUS_NOT_FOUND = 404, 582 HTTP_STATUS_BAD_METHOD = 405, 583 HTTP_STATUS_NONE_ACCEPTABLE = 406, 584 HTTP_STATUS_PROXY_AUTH_REQ = 407, 585 HTTP_STATUS_REQUEST_TIMEOUT = 408, 586 HTTP_STATUS_CONFLICT = 409, 587 HTTP_STATUS_GONE = 410, 588 HTTP_STATUS_LENGTH_REQUIRED = 411, 589 HTTP_STATUS_PRECOND_FAILED = 412, 590 HTTP_STATUS_REQUEST_TOO_LARGE = 413, 591 HTTP_STATUS_URI_TOO_LONG = 414, 592 HTTP_STATUS_UNSUPPORTED_MEDIA = 415, 593 HTTP_STATUS_RETRY_WITH = 449, 594 595 HTTP_STATUS_SERVER_ERROR = 500, 596 HTTP_STATUS_NOT_SUPPORTED = 501, 597 HTTP_STATUS_BAD_GATEWAY = 502, 598 HTTP_STATUS_SERVICE_UNAVAIL = 503, 599 HTTP_STATUS_GATEWAY_TIMEOUT = 504, 600 HTTP_STATUS_VERSION_NOT_SUP = 505, 601 602 HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE, 603 HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP 604} 605 606enum LPCWSTR WINHTTP_NO_REFERER = null; 607enum LPCWSTR * WINHTTP_DEFAULT_ACCEPT_TYPES = null; 608 609enum : DWORD { 610 WINHTTP_ADDREQ_INDEX_MASK = 0x0000FFFF, 611 WINHTTP_ADDREQ_FLAGS_MASK = 0xFFFF0000, 612 613 WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = 0x10000000, 614 615 WINHTTP_ADDREQ_FLAG_ADD = 0x20000000, 616 617 WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = 0x40000000, 618 WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = 0x01000000, 619 WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA, 620 621 WINHTTP_ADDREQ_FLAG_REPLACE = 0x80000000, 622 623 WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0 624} 625 626enum LPCWSTR WINHTTP_NO_ADDITIONAL_HEADERS = null; 627enum LPVOID WINHTTP_NO_REQUEST_DATA = null; 628 629enum LPCWSTR WINHTTP_HEADER_NAME_BY_INDEX = null; 630enum LPVOID WINHTTP_NO_OUTPUT_BUFFER = null; 631enum LPDWORD WINHTTP_NO_HEADER_INDEX = null; 632 633struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG { 634 BOOL fAutoDetect; 635 LPWSTR lpszAutoConfigUrl; 636 LPWSTR lpszProxy; 637 LPWSTR lpszProxyBypass; 638} 639 640// WinHttp API error returns 641enum : DWORD { 642 WINHTTP_ERROR_BASE = 12000, 643 644 ERROR_WINHTTP_OUT_OF_HANDLES = (WINHTTP_ERROR_BASE + 1), 645 ERROR_WINHTTP_TIMEOUT = (WINHTTP_ERROR_BASE + 2), 646 ERROR_WINHTTP_INTERNAL_ERROR = (WINHTTP_ERROR_BASE + 4), 647 ERROR_WINHTTP_INVALID_URL = (WINHTTP_ERROR_BASE + 5), 648 ERROR_WINHTTP_UNRECOGNIZED_SCHEME = (WINHTTP_ERROR_BASE + 6), 649 ERROR_WINHTTP_NAME_NOT_RESOLVED = (WINHTTP_ERROR_BASE + 7), 650 ERROR_WINHTTP_INVALID_OPTION = (WINHTTP_ERROR_BASE + 9), 651 ERROR_WINHTTP_OPTION_NOT_SETTABLE = (WINHTTP_ERROR_BASE + 11), 652 ERROR_WINHTTP_SHUTDOWN = (WINHTTP_ERROR_BASE + 12), 653 654 ERROR_WINHTTP_LOGIN_FAILURE = (WINHTTP_ERROR_BASE + 15), 655 ERROR_WINHTTP_OPERATION_CANCELLED = (WINHTTP_ERROR_BASE + 17), 656 ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = (WINHTTP_ERROR_BASE + 18), 657 ERROR_WINHTTP_INCORRECT_HANDLE_STATE = (WINHTTP_ERROR_BASE + 19), 658 ERROR_WINHTTP_CANNOT_CONNECT = (WINHTTP_ERROR_BASE + 29), 659 ERROR_WINHTTP_CONNECTION_ERROR = (WINHTTP_ERROR_BASE + 30), 660 ERROR_WINHTTP_RESEND_REQUEST = (WINHTTP_ERROR_BASE + 32), 661 662 ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE + 44), 663 664 ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = (WINHTTP_ERROR_BASE + 100), 665 ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = (WINHTTP_ERROR_BASE + 101), 666 ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = (WINHTTP_ERROR_BASE + 102), 667 ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = (WINHTTP_ERROR_BASE + 103), 668 669 ERROR_WINHTTP_HEADER_NOT_FOUND = (WINHTTP_ERROR_BASE + 150), 670 ERROR_WINHTTP_INVALID_SERVER_RESPONSE = (WINHTTP_ERROR_BASE + 152), 671 ERROR_WINHTTP_INVALID_HEADER = (WINHTTP_ERROR_BASE + 153), 672 ERROR_WINHTTP_INVALID_QUERY_REQUEST = (WINHTTP_ERROR_BASE + 154), 673 ERROR_WINHTTP_HEADER_ALREADY_EXISTS = (WINHTTP_ERROR_BASE + 155), 674 ERROR_WINHTTP_REDIRECT_FAILED = (WINHTTP_ERROR_BASE + 156), 675 676 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = (WINHTTP_ERROR_BASE + 178), 677 ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = (WINHTTP_ERROR_BASE + 166), 678 ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = (WINHTTP_ERROR_BASE + 167), 679 ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE = (WINHTTP_ERROR_BASE + 176), 680 ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR = (WINHTTP_ERROR_BASE + 177), 681 682 ERROR_WINHTTP_NOT_INITIALIZED = (WINHTTP_ERROR_BASE + 172), 683 ERROR_WINHTTP_SECURE_FAILURE = (WINHTTP_ERROR_BASE + 175), 684 685 ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = (WINHTTP_ERROR_BASE + 37), 686 ERROR_WINHTTP_SECURE_CERT_CN_INVALID = (WINHTTP_ERROR_BASE + 38), 687 ERROR_WINHTTP_SECURE_INVALID_CA = (WINHTTP_ERROR_BASE + 45), 688 ERROR_WINHTTP_SECURE_CERT_REV_FAILED = (WINHTTP_ERROR_BASE + 57), 689 ERROR_WINHTTP_SECURE_CHANNEL_ERROR = (WINHTTP_ERROR_BASE + 157), 690 ERROR_WINHTTP_SECURE_INVALID_CERT = (WINHTTP_ERROR_BASE + 169), 691 ERROR_WINHTTP_SECURE_CERT_REVOKED = (WINHTTP_ERROR_BASE + 170), 692 ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = (WINHTTP_ERROR_BASE + 179), 693 694 ERROR_WINHTTP_AUTODETECTION_FAILED = (WINHTTP_ERROR_BASE + 180), 695 ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = (WINHTTP_ERROR_BASE + 181), 696 ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = (WINHTTP_ERROR_BASE + 182), 697 ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = (WINHTTP_ERROR_BASE + 183), 698 ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = (WINHTTP_ERROR_BASE + 184), 699 ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = (WINHTTP_ERROR_BASE + 185), 700 ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = (WINHTTP_ERROR_BASE + 186), 701 702 WINHTTP_ERROR_LAST = (WINHTTP_ERROR_BASE + 186) 703} 704 705enum : DWORD { 706 WINHTTP_RESET_STATE = 0x00000001, 707 WINHTTP_RESET_SWPAD_CURRENT_NETWORK = 0x00000002, 708 WINHTTP_RESET_SWPAD_ALL = 0x00000004, 709 WINHTTP_RESET_SCRIPT_CACHE = 0x00000008, 710 WINHTTP_RESET_ALL = 0x0000FFFF, 711 WINHTTP_RESET_NOTIFY_NETWORK_CHANGED = 0x00010000, 712 WINHTTP_RESET_OUT_OF_PROC = 0x00020000 713} 714 715enum : DWORD { 716 WINHTTP_WEB_SOCKET_MAX_CLOSE_REASON_LENGTH = 123, 717 WINHTTP_WEB_SOCKET_MIN_KEEPALIVE_VALUE = 15000 718} 719 720// Version(Windows8) || Version(Windows2012): 721static if (_WIN32_WINNT >= 0x602) 722{ 723 enum WINHTTP_WEB_SOCKET_OPERATION : DWORD 724 { 725 WINHTTP_WEB_SOCKET_SEND_OPERATION = 0, 726 WINHTTP_WEB_SOCKET_RECEIVE_OPERATION = 1, 727 WINHTTP_WEB_SOCKET_CLOSE_OPERATION = 2, 728 WINHTTP_WEB_SOCKET_SHUTDOWN_OPERATION = 3 729 } 730 enum WINHTTP_WEB_SOCKET_BUFFER_TYPE : DWORD 731 { 732 WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = 0, 733 WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = 1, 734 WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE = 2, 735 WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE = 3, 736 WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE = 4 737 } 738 enum WINHTTP_WEB_SOCKET_CLOSE_STATUS : DWORD 739 { 740 WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS = 1000, 741 WINHTTP_WEB_SOCKET_ENDPOINT_TERMINATED_CLOSE_STATUS = 1001, 742 WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS = 1002, 743 WINHTTP_WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS = 1003, 744 WINHTTP_WEB_SOCKET_EMPTY_CLOSE_STATUS = 1005, 745 WINHTTP_WEB_SOCKET_ABORTED_CLOSE_STATUS = 1006, 746 WINHTTP_WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS = 1007, 747 WINHTTP_WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS = 1008, 748 WINHTTP_WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS = 1009, 749 WINHTTP_WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010, 750 WINHTTP_WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS = 1011, 751 WINHTTP_WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015 752 } 753 struct WINHTTP_PROXY_RESULT_ENTRY { 754 BOOL fProxy; 755 BOOL fBypass; 756 INTERNET_SCHEME ProxyScheme; 757 PWSTR pwszProxy; 758 INTERNET_PORT ProxyPort; 759 } 760 struct WINHTTP_PROXY_RESULT { 761 DWORD cEntries; 762 WINHTTP_PROXY_RESULT_ENTRY *pEntries; 763 } 764 struct WINHTTP_WEB_SOCKET_ASYNC_RESULT { 765 WINHTTP_ASYNC_RESULT AsyncResult; 766 WINHTTP_WEB_SOCKET_OPERATION Operation; 767 } 768 struct WINHTTP_WEB_SOCKET_STATUS { 769 DWORD dwBytesTransferred; 770 WINHTTP_WEB_SOCKET_BUFFER_TYPE eBufferType; 771 } 772} 773 774 775extern (Windows) { 776 BOOL WinHttpAddRequestHeaders(HINTERNET hRequest, LPCWSTR pwszHeaders, DWORD dwHeadersLength, DWORD dwModifiers); 777 778 BOOL WinHttpCheckPlatform(); 779 780 BOOL WinHttpCloseHandle(HINTERNET hInternet); 781 782 HINTERNET WinHttpConnect(HINTERNET hSession, LPCWSTR pswzServerName, INTERNET_PORT nServerPort, DWORD dwReserved); 783 784 BOOL WinHttpCrackUrl(LPCWSTR pwszUrl, DWORD dwUrlLength, DWORD dwFlags, LPURL_COMPONENTS lpUrlComponents); 785 786 BOOL WinHttpCreateUrl(LPURL_COMPONENTS lpUrlComponents, DWORD dwFlags, LPWSTR pwszUrl, LPDWORD lpdwUrlLength); 787 BOOL WinHttpDetectAutoProxyConfigUrl(DWORD dwAutoDetectFlags, LPWSTR *ppwszAutoConfigUrl); 788 789 BOOL WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *pProxyInfo); 790 BOOL WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *pProxyConfig); 791 BOOL WinHttpGetProxyForUrl(HINTERNET hSession, LPCWSTR lpcwszUrl, 792 WINHTTP_AUTOPROXY_OPTIONS *pAutoProxyOptions, WINHTTP_PROXY_INFO *pProxyInfo); 793 794 HINTERNET WinHttpOpen(LPCWSTR pwszUserAgent, DWORD dwAccessType, LPCWSTR pwszProxyName, 795 LPCWSTR pwszProxyBypass, DWORD dwFlags); 796 HINTERNET WinHttpOpenRequest(HINTERNET hConnect, LPCWSTR pwszVerb, LPCWSTR pwszObjectName, 797 LPCWSTR pwszVersion, LPCWSTR pwszReferrer, 798 LPCWSTR *ppwszAcceptTypes, DWORD dwFlags); 799 800 BOOL WinHttpQueryAuthSchemes(HINTERNET hRequest, LPDWORD lpdwSupportedSchemes, 801 LPDWORD lpdwFirstScheme, LPDWORD pdwAuthTarget); 802 BOOL WinHttpQueryDataAvailable(HINTERNET hRequest, LPDWORD lpdwNumberOfBytesAvailable); 803 BOOL WinHttpQueryHeaders(HINTERNET hRequest, DWORD dwInfoLevel, LPCWSTR pwszName, 804 LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex); 805 BOOL WinHttpQueryOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, 806 LPDWORD lpdwBufferLength); 807 808 BOOL WinHttpReadData(HINTERNET hRequest, LPVOID lpBuffer, DWORD dwNumberOfBytesToRead, 809 LPDWORD lpdwNumberOfBytesRead); 810 BOOL WinHttpReceiveResponse(HINTERNET hRequest, LPVOID lpReserved); 811 812 BOOL WinHttpSendRequest(HINTERNET hRequest, LPCWSTR pwszHeaders, DWORD dwHeadersLength, 813 LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwTotalLength, DWORD_PTR dwContext); 814 815 BOOL WinHttpSetCredentials(HINTERNET hRequest, DWORD AuthTargets, DWORD AuthScheme, 816 LPCWSTR pwszUserName, LPCWSTR pwszPassword, LPVOID pAuthParams); 817 BOOL WinHttpSetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *pProxyInfo); 818 BOOL WinHttpSetOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength); 819 WINHTTP_STATUS_CALLBACK WinHttpSetStatusCallback(HINTERNET hInternet, 820 WINHTTP_STATUS_CALLBACK lpfnInternetCallback, 821 DWORD dwNotificationFlags, DWORD_PTR dwReserved); 822 BOOL WinHttpSetTimeouts(HINTERNET hInternet, int dwResolveTimeout, int dwConnectTimeout, 823 int dwSendTimeout, int dwReceiveTimeout); 824 825 BOOL WinHttpTimeFromSystemTime(const SYSTEMTIME *pst, LPWSTR pwszTime); 826 BOOL WinHttpTimeToSystemTime(LPCWSTR pwszTime, SYSTEMTIME *pst); 827 828 BOOL WinHttpWriteData(HINTERNET hRequest, LPCVOID lpBuffer, DWORD dwNumberOfBytesToWrite, 829 LPDWORD lpdwNumberOfBytesWritten); 830 831 // Version(Windows8) || Version(Windows2012): 832 static if (_WIN32_WINNT >= 0x602) { 833 DWORD WinHttpCreateProxyResolver(HINTERNET hSession, HINTERNET *phResolver); 834 void WinHttpFreeProxyResult(WINHTTP_PROXY_RESULT *pProxyResult); 835 DWORD WinHttpGetProxyForUrlEx(HINTERNET hResolver, PCWSTR pcwszUrl, 836 WINHTTP_AUTOPROXY_OPTIONS *pAutoProxyOptions, DWORD_PTR pContext); 837 DWORD WinHttpGetProxyResult(HINTERNET hResolver, WINHTTP_PROXY_RESULT *pProxyResult); 838 DWORD WinHttpResetAutoProxy(HINTERNET hSession, DWORD dwFlags); 839 DWORD WinHttpWebSocketClose(HINTERNET hWebSocket, USHORT usStatus, PVOID pvReason, DWORD dwReasonLength); 840 HINTERNET WinHttpWebSocketCompleteUpgrade(HINTERNET hRequest, DWORD_PTR pContext); 841 DWORD WinHttpWebSocketQueryCloseStatus(HINTERNET hWebSocket, USHORT *pusStatus, PVOID pvReason, 842 DWORD dwReasonLength, DWORD *pdwReasonLengthConsumed); 843 DWORD WinHttpWebSocketReceive(HINTERNET hWebSocket, PVOID pvBuffer, DWORD dwBufferLength, 844 DWORD *pdwBytesRead, WINHTTP_WEB_SOCKET_BUFFER_TYPE *peBufferType); 845 DWORD WinHttpWebSocketSend(HINTERNET hWebSocket, WINHTTP_WEB_SOCKET_BUFFER_TYPE eBufferType, 846 PVOID pvBuffer, DWORD dwBufferLength); 847 DWORD WinHttpWebSocketShutdown(HINTERNET hWebSocket, USHORT usStatus, PVOID pvReason, DWORD dwReasonLength); 848 } 849} 850