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