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