EnumThemeColors() and EnumThemeSizes() actually do not return a single
[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 inline void copy_compsA(
288     URL_COMPONENTSA *src, 
289     URL_COMPONENTSA *dst, 
290     DWORD scheLen,
291     DWORD hostLen,
292     DWORD userLen,
293     DWORD passLen,
294     DWORD pathLen,
295     DWORD extrLen )
296 {
297     *dst = *src;
298     dst->dwSchemeLength    = scheLen;
299     dst->dwHostNameLength  = hostLen;
300     dst->dwUserNameLength  = userLen;
301     dst->dwPasswordLength  = passLen;
302     dst->dwUrlPathLength   = pathLen;
303     dst->dwExtraInfoLength = extrLen;
304     SetLastError(0xfaceabad);
305 }
306   
307 static inline void zero_compsA(
308     URL_COMPONENTSA *dst, 
309     DWORD scheLen,
310     DWORD hostLen,
311     DWORD userLen,
312     DWORD passLen,
313     DWORD pathLen,
314     DWORD extrLen )
315 {
316     ZeroMemory(dst, sizeof(URL_COMPONENTSA));
317     dst->dwStructSize = sizeof(URL_COMPONENTSA);
318     dst->dwSchemeLength    = scheLen;
319     dst->dwHostNameLength  = hostLen;
320     dst->dwUserNameLength  = userLen;
321     dst->dwPasswordLength  = passLen;
322     dst->dwUrlPathLength   = pathLen;
323     dst->dwExtraInfoLength = extrLen;
324     SetLastError(0xfaceabad);
325 }
326   
327 static void InternetCrackUrl_test(void)
328 {
329   URL_COMPONENTSA urlSrc, urlComponents;
330   char protocol[32], hostName[1024], userName[1024];
331   char password[1024], extra[1024], path[1024];
332   BOOL ret;
333   DWORD GLE;
334
335   ZeroMemory(&urlSrc, sizeof(urlSrc));
336   urlSrc.dwStructSize = sizeof(urlSrc);
337   urlSrc.lpszScheme = protocol;
338   urlSrc.lpszHostName = hostName;
339   urlSrc.lpszUserName = userName;
340   urlSrc.lpszPassword = password;
341   urlSrc.lpszUrlPath = path;
342   urlSrc.lpszExtraInfo = extra;
343
344   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
345   ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
346   ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
347   ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
348
349   /* Bug 1805: Confirm the returned lengths are correct:                     */
350   /* 1. When extra info split out explicitly */
351   zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
352   ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error 0x%lx\n", GetLastError());
353   ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
354   ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
355   ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
356   ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
357   ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %ld\n", strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
358   ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
359
360   /* 2. When extra info is not split out explicitly and is in url path */
361   zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
362   ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
363   ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
364   ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
365   ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
366   ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
367
368   /*3. Check for %20 */
369   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
370   ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
371
372
373   /* Tests for lpsz* members pointing to real strings while 
374    * some corresponding length members are set to zero */
375   copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024);
376   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
377   ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
378     ret, GetLastError());
379
380   copy_compsA(&urlSrc, &urlComponents, 32, 0, 1024, 1024, 2048, 1024);
381   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
382   ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
383     ret, GetLastError());
384
385   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 0, 1024, 2048, 1024);
386   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
387   ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
388     ret, GetLastError());
389
390   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 0, 2048, 1024);
391   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
392   ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
393     ret, GetLastError());
394
395   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 0, 1024);
396   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
397   GLE = GetLastError();
398   todo_wine
399   ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER),
400      "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
401     ret, GLE);
402
403   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 0);
404   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
405   GLE = GetLastError();
406   todo_wine
407   ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER),
408      "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
409     ret, GLE);
410
411   copy_compsA(&urlSrc, &urlComponents, 0, 0, 0, 0, 0, 0);
412   ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
413   GLE = GetLastError();
414   todo_wine
415   ok(ret==0 && GLE==ERROR_INVALID_PARAMETER,
416      "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_PARAMETER)\n",
417     ret, GLE);
418 }
419
420 static void InternetCrackUrlW_test(void)
421 {
422     WCHAR url[] = {
423         'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
424         'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
425         '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
426         'U','L','T', 0 };
427     URL_COMPONENTSW comp;
428     WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
429     BOOL r;
430
431     urlpart[0]=0;
432     scheme[0]=0;
433     extra[0]=0;
434     host[0]=0;
435     user[0]=0;
436     pwd[0]=0;
437     memset(&comp, 0, sizeof comp);
438     comp.dwStructSize = sizeof comp;
439     comp.lpszScheme = scheme;
440     comp.dwSchemeLength = sizeof scheme;
441     comp.lpszHostName = host;
442     comp.dwHostNameLength = sizeof host;
443     comp.lpszUserName = user;
444     comp.dwUserNameLength = sizeof user;
445     comp.lpszPassword = pwd;
446     comp.dwPasswordLength = sizeof pwd;
447     comp.lpszUrlPath = urlpart;
448     comp.dwUrlPathLength = sizeof urlpart;
449     comp.lpszExtraInfo = extra;
450     comp.dwExtraInfoLength = sizeof extra;
451
452     r = InternetCrackUrlW(url, 0, 0, &comp );
453     ok( r, "failed to crack url\n");
454     ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
455     ok( comp.dwHostNameLength == 12, "host length wrong\n");
456     ok( comp.dwUserNameLength == 0, "user length wrong\n");
457     ok( comp.dwPasswordLength == 0, "password length wrong\n");
458     ok( comp.dwUrlPathLength == 15, "url length wrong\n");
459     ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
460  
461     urlpart[0]=0;
462     scheme[0]=0;
463     extra[0]=0;
464     host[0]=0;
465     user[0]=0;
466     pwd[0]=0;
467     memset(&comp, 0, sizeof comp);
468     comp.dwStructSize = sizeof comp;
469     comp.lpszHostName = host;
470     comp.dwHostNameLength = sizeof host;
471     comp.lpszUrlPath = urlpart;
472     comp.dwUrlPathLength = sizeof urlpart;
473
474     r = InternetCrackUrlW(url, 0, 0, &comp );
475     ok( r, "failed to crack url\n");
476     ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
477     ok( comp.dwHostNameLength == 12, "host length wrong\n");
478     ok( comp.dwUserNameLength == 0, "user length wrong\n");
479     ok( comp.dwPasswordLength == 0, "password length wrong\n");
480     ok( comp.dwUrlPathLength == 44, "url length wrong\n");
481     ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
482
483     urlpart[0]=0;
484     scheme[0]=0;
485     extra[0]=0;
486     host[0]=0;
487     user[0]=0;
488     pwd[0]=0;
489     memset(&comp, 0, sizeof comp);
490     comp.dwStructSize = sizeof comp;
491     comp.lpszHostName = host;
492     comp.dwHostNameLength = sizeof host;
493     comp.lpszUrlPath = urlpart;
494     comp.dwUrlPathLength = sizeof urlpart;
495     comp.lpszExtraInfo = NULL;
496     comp.dwExtraInfoLength = sizeof extra;
497
498     r = InternetCrackUrlW(url, 0, 0, &comp );
499     ok( r, "failed to crack url\n");
500     ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
501     ok( comp.dwHostNameLength == 12, "host length wrong\n");
502     ok( comp.dwUserNameLength == 0, "user length wrong\n");
503     ok( comp.dwPasswordLength == 0, "password length wrong\n");
504     ok( comp.dwUrlPathLength == 15, "url length wrong\n");
505     ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
506 }
507
508 static void InternetTimeFromSystemTimeA_test(void)
509 {
510     BOOL ret;
511     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
512     char string[INTERNET_RFC1123_BUFSIZE];
513     static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
514
515     ret = InternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
516     ok( ret, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
517
518     ok( !memcmp( string, expect, sizeof(expect) ),
519         "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
520 }
521
522 static void InternetTimeFromSystemTimeW_test(void)
523 {
524     BOOL ret;
525     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
526     WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
527     static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
528                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
529
530     ret = InternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
531     ok( ret, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
532
533     ok( !memcmp( string, expect, sizeof(expect) ),
534         "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
535 }
536
537 static void InternetTimeToSystemTimeA_test(void)
538 {
539     BOOL ret;
540     SYSTEMTIME time;
541     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
542     static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
543     static const char string2[] = " fri 7 jan 2005 12 06 35";
544
545     ret = InternetTimeToSystemTimeA( string, &time, 0 );
546     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
547     ok( !memcmp( &time, &expect, sizeof(expect) ),
548         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
549
550     ret = InternetTimeToSystemTimeA( string2, &time, 0 );
551     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
552     ok( !memcmp( &time, &expect, sizeof(expect) ),
553         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
554 }
555
556 static void InternetTimeToSystemTimeW_test(void)
557 {
558     BOOL ret;
559     SYSTEMTIME time;
560     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
561     static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
562                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
563     static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
564                                      '1','2',' ','0','6',' ','3','5',0 };
565     static const WCHAR string3[] = { 'F','r',0 };
566
567     ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
568     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
569
570     ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
571     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
572
573     ret = InternetTimeToSystemTimeW( string, NULL, 0 );
574     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
575
576     ret = InternetTimeToSystemTimeW( string, &time, 1 );
577     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
578
579     ret = InternetTimeToSystemTimeW( string, &time, 0 );
580     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
581     ok( !memcmp( &time, &expect, sizeof(expect) ),
582         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
583
584     ret = InternetTimeToSystemTimeW( string2, &time, 0 );
585     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
586     ok( !memcmp( &time, &expect, sizeof(expect) ),
587         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
588
589     ret = InternetTimeToSystemTimeW( string3, &time, 0 );
590     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
591 }
592
593 START_TEST(http)
594 {
595     winapi_test(0x10000000);
596     winapi_test(0x00000000);
597     InternetCrackUrl_test();
598     InternetOpenUrlA_test();
599     InternetCrackUrlW_test();
600     InternetTimeFromSystemTimeA_test();
601     InternetTimeFromSystemTimeW_test();
602     InternetTimeToSystemTimeA_test();
603     InternetTimeToSystemTimeW_test();
604 }