Don't open device if already open.
[wine] / dlls / wininet / tests / http.c
1 #include <stdarg.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include "windef.h"
6 #include "winbase.h"
7 #include "wininet.h"
8
9 #include "wine/test.h"
10
11 #define TEST_URL "http://www.winehq.org/site/about"
12 #define TEST_URL_PATH "/site/about"
13 #define TEST_URL2 "http://www.myserver.com/myscript.php?arg=1"
14 #define TEST_URL2_SERVER "www.myserver.com"
15 #define TEST_URL2_PATH "/myscript.php"
16 #define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
17 #define TEST_URL2_EXTRA "?arg=1"
18 #define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
19
20 int goon = 0;
21
22 VOID WINAPI callback(
23      HINTERNET hInternet,
24      DWORD dwContext,
25      DWORD dwInternetStatus,
26      LPVOID lpvStatusInformation,
27      DWORD dwStatusInformationLength
28 )
29 {
30     char name[124];
31
32     switch (dwInternetStatus)
33     {
34         case INTERNET_STATUS_RESOLVING_NAME:
35             strcpy(name,"INTERNET_STATUS_RESOLVING_NAME");
36             break;
37         case INTERNET_STATUS_NAME_RESOLVED:
38             strcpy(name,"INTERNET_STATUS_NAME_RESOLVED");
39             break;
40         case INTERNET_STATUS_CONNECTING_TO_SERVER:
41             strcpy(name,"INTERNET_STATUS_CONNECTING_TO_SERVER");
42             break;
43         case INTERNET_STATUS_CONNECTED_TO_SERVER:
44             strcpy(name,"INTERNET_STATUS_CONNECTED_TO_SERVER");
45             break;
46         case INTERNET_STATUS_SENDING_REQUEST:
47             strcpy(name,"INTERNET_STATUS_SENDING_REQUEST");
48             break;
49         case INTERNET_STATUS_REQUEST_SENT:
50             strcpy(name,"INTERNET_STATUS_REQUEST_SENT");
51             break;
52         case INTERNET_STATUS_RECEIVING_RESPONSE:
53             strcpy(name,"INTERNET_STATUS_RECEIVING_RESPONSE");
54             break;
55         case INTERNET_STATUS_RESPONSE_RECEIVED:
56             strcpy(name,"INTERNET_STATUS_RESPONSE_RECEIVED");
57             break;
58         case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
59             strcpy(name,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
60             break;
61         case INTERNET_STATUS_PREFETCH:
62             strcpy(name,"INTERNET_STATUS_PREFETCH");
63             break;
64         case INTERNET_STATUS_CLOSING_CONNECTION:
65             strcpy(name,"INTERNET_STATUS_CLOSING_CONNECTION");
66             break;
67         case INTERNET_STATUS_CONNECTION_CLOSED:
68             strcpy(name,"INTERNET_STATUS_CONNECTION_CLOSED");
69             break;
70         case INTERNET_STATUS_HANDLE_CREATED:
71             strcpy(name,"INTERNET_STATUS_HANDLE_CREATED");
72             break;
73         case INTERNET_STATUS_HANDLE_CLOSING:
74             strcpy(name,"INTERNET_STATUS_HANDLE_CLOSING");
75             break;
76         case INTERNET_STATUS_REQUEST_COMPLETE:
77             strcpy(name,"INTERNET_STATUS_REQUEST_COMPLETE");
78             goon = 1;
79             break;
80         case INTERNET_STATUS_REDIRECT:
81             strcpy(name,"INTERNET_STATUS_REDIRECT");
82             break;
83         case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
84             strcpy(name,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
85             break;
86     }
87
88     trace("Callback %p 0x%lx %s(%li) %p %ld\n",hInternet,dwContext,name,dwInternetStatus,lpvStatusInformation,dwStatusInformationLength);
89 }
90
91 void winapi_test(int flags)
92 {
93     DWORD rc;
94     CHAR buffer[4000];
95     DWORD length;
96     DWORD out;
97     const char *types[2] = { "*", NULL };
98     HINTERNET hi, hic = 0, hor = 0;
99
100     trace("Starting with flags 0x%x\n",flags);
101
102     trace("InternetOpenA <--\n");
103     hi = InternetOpenA("",0x0,0x0,0x0,flags);
104     ok((hi != 0x0),"InternetOpen Failed\n");
105     trace("InternetOpenA -->\n");
106
107     if (hi == 0x0) goto abort;
108
109     InternetSetStatusCallback(hi,&callback);
110
111     trace("InternetConnectA <--\n");
112     hic=InternetConnectA(hi,"www.winehq.org",0x0,0x0,0x0,0x3,0x0,0xdeadbeef);
113     ok((hic != 0x0),"InternetConnect Failed\n");
114     trace("InternetConnectA -->\n");
115
116     if (hic == 0x0) goto abort;
117
118     trace("HttpOpenRequestA <--\n");
119     hor = HttpOpenRequestA(hic, "GET",
120                           "/about/",
121                           0x0,0x0,types,0x00400800,0xdeadbead);
122     if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) {
123         /*
124          * If the internet name can't be resolved we are probably behind
125          * a firewall or in some other way not directly connected to the
126          * Internet. Not enough reason to fail the test. Just ignore and
127          * abort.
128          */
129     } else  {
130         ok((hor != 0x0),"HttpOpenRequest Failed\n");
131     }
132     trace("HttpOpenRequestA -->\n");
133
134     if (hor == 0x0) goto abort;
135
136     trace("HttpSendRequestA -->\n");
137     SetLastError(0);
138     rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
139     if (flags)
140         ok(((rc == 0)&&(GetLastError()==997)),
141             "Asynchronous HttpSendRequest NOT returning 0 with error 997\n");
142     else
143         ok((rc != 0) || GetLastError() == 12007, /* 12007 == XP */
144            "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
145     trace("HttpSendRequestA <--\n");
146
147     while ((flags)&&(!goon))
148         Sleep(100);
149
150     length = 4;
151     rc = InternetQueryOptionA(hor,0x17,&out,&length);
152     trace("Option 0x17 -> %li  %li\n",rc,out);
153
154     length = 100;
155     rc = InternetQueryOptionA(hor,0x22,buffer,&length);
156     trace("Option 0x22 -> %li  %s\n",rc,buffer);
157
158     length = 4000;
159     rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
160     buffer[length]=0;
161     trace("Option 0x16 -> %li  %s\n",rc,buffer);
162
163     length = 4000;
164     rc = InternetQueryOptionA(hor,0x22,buffer,&length);
165     buffer[length]=0;
166     trace("Option 0x22 -> %li  %s\n",rc,buffer);
167
168     length = 16;
169     rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
170     trace("Option 0x5 -> %li  %s  (%li)\n",rc,buffer,GetLastError());
171
172     length = 100;
173     rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
174     buffer[length]=0;
175     trace("Option 0x1 -> %li  %s\n",rc,buffer);
176
177     length = 100;
178     trace("Entering Query loop\n");
179
180     while (length)
181     {
182
183         rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
184         ok(!(rc == 0 && length != 0),"InternetQueryDataAvailable failed\n");
185
186         if (length)
187         {
188             char *buffer;
189             buffer = HeapAlloc(GetProcessHeap(),0,length+1);
190
191             rc = InternetReadFile(hor,buffer,length,&length);
192
193             buffer[length]=0;
194
195             trace("ReadFile -> %li %li\n",rc,length);
196
197             HeapFree(GetProcessHeap(),0,buffer);
198         }
199     }
200 abort:
201     if (hor != 0x0) {
202         rc = InternetCloseHandle(hor);
203         ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
204         rc = InternetCloseHandle(hor);
205         ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
206     }
207     if (hic != 0x0) {
208         rc = InternetCloseHandle(hic);
209         ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
210     }
211     if (hi != 0x0) {
212       rc = InternetCloseHandle(hi);
213       ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
214       if (flags)
215           Sleep(100);
216     }
217 }
218
219 void InternetOpenUrlA_test(void)
220 {
221   HINTERNET myhinternet, myhttp;
222   char buffer[0x400];
223   URL_COMPONENTSA urlComponents;
224   char protocol[32], hostName[1024], userName[1024];
225   char password[1024], extra[1024], path[1024];
226   DWORD size, readbytes, totalbytes=0;
227   BOOL ret;
228   
229   myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
230   ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
231   size = 0x400;
232   ret = InternetCanonicalizeUrl(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
233   ok( ret, "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
234   
235   urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
236   urlComponents.lpszScheme = protocol;
237   urlComponents.dwSchemeLength = 32;
238   urlComponents.lpszHostName = hostName;
239   urlComponents.dwHostNameLength = 1024;
240   urlComponents.lpszUserName = userName;
241   urlComponents.dwUserNameLength = 1024;
242   urlComponents.lpszPassword = password;
243   urlComponents.dwPasswordLength = 1024;
244   urlComponents.lpszUrlPath = path;
245   urlComponents.dwUrlPathLength = 2048;
246   urlComponents.lpszExtraInfo = extra;
247   urlComponents.dwExtraInfoLength = 1024;
248   ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
249   ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
250   SetLastError(0);
251   myhttp = InternetOpenUrl(myhinternet, TEST_URL, 0, 0,
252                            INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
253   if (GetLastError() == 12007)
254     return; /* WinXP returns this when not connected to the net */
255   ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
256   ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
257   ok( ret, "InternetReadFile failed, error %lx\n",GetLastError());
258   totalbytes += readbytes;
259   while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
260     totalbytes += readbytes;
261   trace("read 0x%08lx bytes\n",totalbytes);
262 }
263   
264 void InternetCrackUrl_test(void)
265 {
266   URL_COMPONENTSA urlComponents;
267   char protocol[32], hostName[1024], userName[1024];
268   char password[1024], extra[1024], path[1024];
269   BOOL ret;
270
271   urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
272   urlComponents.lpszScheme = protocol;
273   urlComponents.dwSchemeLength = 32;
274   urlComponents.lpszHostName = hostName;
275   urlComponents.dwHostNameLength = 1024;
276   urlComponents.lpszUserName = userName;
277   urlComponents.dwUserNameLength = 1024;
278   urlComponents.lpszPassword = password;
279   urlComponents.dwPasswordLength = 1024;
280   urlComponents.lpszUrlPath = path;
281   urlComponents.dwUrlPathLength = 2048;
282   urlComponents.lpszExtraInfo = extra;
283   urlComponents.dwExtraInfoLength = 1024;
284   ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
285   ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
286   ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
287
288   /* Bug 1805: Confirm the returned lengths are correct:                     */
289   /* 1. When extra info split out explicitly */
290   ZeroMemory(&urlComponents, sizeof(urlComponents));
291   urlComponents.dwStructSize = sizeof(urlComponents);
292   urlComponents.dwHostNameLength = 1;
293   urlComponents.dwUrlPathLength  = 1;
294   urlComponents.dwExtraInfoLength = 1;
295   ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error 0x%lx\n", GetLastError());
296   ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
297   ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
298   ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
299   ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
300   ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %ld\n", strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
301   ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
302
303   /* 2. When extra info is not split out explicitly and is in url path */
304   ZeroMemory(&urlComponents, sizeof(urlComponents));
305   urlComponents.dwStructSize = sizeof(urlComponents);
306   urlComponents.dwHostNameLength = 1;
307   urlComponents.dwUrlPathLength  = 1;
308   ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
309   ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
310   ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
311   ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
312   ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
313
314   /*3. Check for %20 */
315   ZeroMemory(&urlComponents, sizeof(urlComponents));
316   urlComponents.dwStructSize = sizeof(urlComponents);
317   urlComponents.lpszScheme = protocol;
318   urlComponents.dwSchemeLength = 32;
319   urlComponents.lpszHostName = hostName;
320   urlComponents.dwHostNameLength = 1024;
321   urlComponents.lpszUserName = userName;
322   urlComponents.dwUserNameLength = 1024;
323   urlComponents.lpszPassword = password;
324   urlComponents.dwPasswordLength = 1024;
325   urlComponents.lpszUrlPath = path;
326   urlComponents.dwUrlPathLength = 2048;
327   urlComponents.lpszExtraInfo = extra;
328   ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
329 }
330
331 void InternetCrackUrlW_test(void)
332 {
333     WCHAR url[] = {
334         'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
335         'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
336         '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
337         'U','L','T', 0 };
338     URL_COMPONENTSW comp;
339     WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
340     BOOL r;
341
342     urlpart[0]=0;
343     scheme[0]=0;
344     extra[0]=0;
345     host[0]=0;
346     user[0]=0;
347     pwd[0]=0;
348     memset(&comp, 0, sizeof comp);
349     comp.dwStructSize = sizeof comp;
350     comp.lpszScheme = scheme;
351     comp.dwSchemeLength = sizeof scheme;
352     comp.lpszHostName = host;
353     comp.dwHostNameLength = sizeof host;
354     comp.lpszUserName = user;
355     comp.dwUserNameLength = sizeof user;
356     comp.lpszPassword = pwd;
357     comp.dwPasswordLength = sizeof pwd;
358     comp.lpszUrlPath = urlpart;
359     comp.dwUrlPathLength = sizeof urlpart;
360     comp.lpszExtraInfo = extra;
361     comp.dwExtraInfoLength = sizeof extra;
362
363     r = InternetCrackUrlW(url, 0, 0, &comp );
364     ok( r, "failed to crack url\n");
365     ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
366     ok( comp.dwHostNameLength == 12, "host length wrong\n");
367     ok( comp.dwUserNameLength == 0, "user length wrong\n");
368     ok( comp.dwPasswordLength == 0, "password length wrong\n");
369     ok( comp.dwUrlPathLength == 15, "url length wrong\n");
370     ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
371  
372     urlpart[0]=0;
373     scheme[0]=0;
374     extra[0]=0;
375     host[0]=0;
376     user[0]=0;
377     pwd[0]=0;
378     memset(&comp, 0, sizeof comp);
379     comp.dwStructSize = sizeof comp;
380     comp.lpszHostName = host;
381     comp.dwHostNameLength = sizeof host;
382     comp.lpszUrlPath = urlpart;
383     comp.dwUrlPathLength = sizeof urlpart;
384
385     r = InternetCrackUrlW(url, 0, 0, &comp );
386     ok( r, "failed to crack url\n");
387     ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
388     ok( comp.dwHostNameLength == 12, "host length wrong\n");
389     ok( comp.dwUserNameLength == 0, "user length wrong\n");
390     ok( comp.dwPasswordLength == 0, "password length wrong\n");
391     ok( comp.dwUrlPathLength == 44, "url length wrong\n");
392     ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
393
394     urlpart[0]=0;
395     scheme[0]=0;
396     extra[0]=0;
397     host[0]=0;
398     user[0]=0;
399     pwd[0]=0;
400     memset(&comp, 0, sizeof comp);
401     comp.dwStructSize = sizeof comp;
402     comp.lpszHostName = host;
403     comp.dwHostNameLength = sizeof host;
404     comp.lpszUrlPath = urlpart;
405     comp.dwUrlPathLength = sizeof urlpart;
406     comp.lpszExtraInfo = NULL;
407     comp.dwExtraInfoLength = sizeof extra;
408
409     r = InternetCrackUrlW(url, 0, 0, &comp );
410     ok( r, "failed to crack url\n");
411     ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
412     ok( comp.dwHostNameLength == 12, "host length wrong\n");
413     ok( comp.dwUserNameLength == 0, "user length wrong\n");
414     ok( comp.dwPasswordLength == 0, "password length wrong\n");
415     ok( comp.dwUrlPathLength == 15, "url length wrong\n");
416     ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
417 }
418
419 static void InternetTimeFromSystemTimeA_test()
420 {
421     BOOL ret;
422     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
423     char string[INTERNET_RFC1123_BUFSIZE];
424     static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
425
426     ret = InternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
427     ok( ret, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
428
429     ok( !memcmp( string, expect, sizeof(expect) ),
430         "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
431 }
432
433 static void InternetTimeFromSystemTimeW_test()
434 {
435     BOOL ret;
436     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
437     WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
438     static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
439                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
440
441     ret = InternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
442     ok( ret, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
443
444     ok( !memcmp( string, expect, sizeof(expect) ),
445         "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
446 }
447
448 static void InternetTimeToSystemTimeA_test()
449 {
450     BOOL ret;
451     SYSTEMTIME time;
452     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
453     static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
454     static const char string2[] = " fri 7 jan 2005 12 06 35";
455
456     ret = InternetTimeToSystemTimeA( string, &time, 0 );
457     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
458     ok( !memcmp( &time, &expect, sizeof(expect) ),
459         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
460
461     ret = InternetTimeToSystemTimeA( string2, &time, 0 );
462     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
463     ok( !memcmp( &time, &expect, sizeof(expect) ),
464         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
465 }
466
467 static void InternetTimeToSystemTimeW_test()
468 {
469     BOOL ret;
470     SYSTEMTIME time;
471     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
472     static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
473                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
474     static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
475                                      '1','2',' ','0','6',' ','3','5',0 };
476     static const WCHAR string3[] = { 'F','r',0 };
477
478     ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
479     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
480
481     ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
482     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
483
484     ret = InternetTimeToSystemTimeW( string, NULL, 0 );
485     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
486
487     ret = InternetTimeToSystemTimeW( string, &time, 1 );
488     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
489
490     ret = InternetTimeToSystemTimeW( string, &time, 0 );
491     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
492     ok( !memcmp( &time, &expect, sizeof(expect) ),
493         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
494
495     ret = InternetTimeToSystemTimeW( string2, &time, 0 );
496     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
497     ok( !memcmp( &time, &expect, sizeof(expect) ),
498         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
499
500     ret = InternetTimeToSystemTimeW( string3, &time, 0 );
501     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
502 }
503
504 START_TEST(http)
505 {
506     winapi_test(0x10000000);
507     winapi_test(0x00000000);
508     InternetCrackUrl_test();
509     InternetOpenUrlA_test();
510     InternetCrackUrlW_test();
511     InternetTimeFromSystemTimeA_test();
512     InternetTimeFromSystemTimeW_test();
513     InternetTimeToSystemTimeA_test();
514     InternetTimeToSystemTimeW_test();
515 }