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