wininet: Add a standalone http test.
[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 #include "winsock.h"
31
32 #include "wine/test.h"
33
34 #define TEST_URL "http://www.winehq.org/site/about"
35
36 static HANDLE hCompleteEvent;
37
38 static VOID WINAPI callback(
39      HINTERNET hInternet,
40      DWORD dwContext,
41      DWORD dwInternetStatus,
42      LPVOID lpvStatusInformation,
43      DWORD dwStatusInformationLength
44 )
45 {
46     switch (dwInternetStatus)
47     {
48         case INTERNET_STATUS_RESOLVING_NAME:
49             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %ld\n",
50                 GetCurrentThreadId(), hInternet, dwContext,
51                 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
52             break;
53         case INTERNET_STATUS_NAME_RESOLVED:
54             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %ld\n",
55                 GetCurrentThreadId(), hInternet, dwContext,
56                 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
57             break;
58         case INTERNET_STATUS_CONNECTING_TO_SERVER:
59             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %ld\n",
60                 GetCurrentThreadId(), hInternet, dwContext,
61                 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
62             break;
63         case INTERNET_STATUS_CONNECTED_TO_SERVER:
64             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %ld\n",
65                 GetCurrentThreadId(), hInternet, dwContext,
66                 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
67             break;
68         case INTERNET_STATUS_SENDING_REQUEST:
69             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %ld\n",
70                 GetCurrentThreadId(), hInternet, dwContext,
71                 lpvStatusInformation,dwStatusInformationLength);
72             break;
73         case INTERNET_STATUS_REQUEST_SENT:
74             ok(dwStatusInformationLength == sizeof(DWORD),
75                 "info length should be sizeof(DWORD) instead of %ld\n",
76                 dwStatusInformationLength);
77             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%lx %ld\n",
78                 GetCurrentThreadId(), hInternet, dwContext,
79                 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
80             break;
81         case INTERNET_STATUS_RECEIVING_RESPONSE:
82             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %ld\n",
83                 GetCurrentThreadId(), hInternet, dwContext,
84                 lpvStatusInformation,dwStatusInformationLength);
85             break;
86         case INTERNET_STATUS_RESPONSE_RECEIVED:
87             ok(dwStatusInformationLength == sizeof(DWORD),
88                 "info length should be sizeof(DWORD) instead of %ld\n",
89                 dwStatusInformationLength);
90             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%lx %ld\n",
91                 GetCurrentThreadId(), hInternet, dwContext,
92                 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
93             break;
94         case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
95             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %ld\n",
96                 GetCurrentThreadId(), hInternet,dwContext,
97                 lpvStatusInformation,dwStatusInformationLength);
98             break;
99         case INTERNET_STATUS_PREFETCH:
100             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %ld\n",
101                 GetCurrentThreadId(), hInternet, dwContext,
102                 lpvStatusInformation,dwStatusInformationLength);
103             break;
104         case INTERNET_STATUS_CLOSING_CONNECTION:
105             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %ld\n",
106                 GetCurrentThreadId(), hInternet, dwContext,
107                 lpvStatusInformation,dwStatusInformationLength);
108             break;
109         case INTERNET_STATUS_CONNECTION_CLOSED:
110             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %ld\n",
111                 GetCurrentThreadId(), hInternet, dwContext,
112                 lpvStatusInformation,dwStatusInformationLength);
113             break;
114         case INTERNET_STATUS_HANDLE_CREATED:
115             ok(dwStatusInformationLength == sizeof(HINTERNET),
116                 "info length should be sizeof(HINTERNET) instead of %ld\n",
117                 dwStatusInformationLength);
118             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %ld\n",
119                 GetCurrentThreadId(), hInternet, dwContext,
120                 *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength);
121             break;
122         case INTERNET_STATUS_HANDLE_CLOSING:
123             ok(dwStatusInformationLength == sizeof(HINTERNET),
124                 "info length should be sizeof(HINTERNET) instead of %ld\n",
125                 dwStatusInformationLength);
126             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %ld\n",
127                 GetCurrentThreadId(), hInternet, dwContext,
128                 *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength);
129             break;
130         case INTERNET_STATUS_REQUEST_COMPLETE:
131         {
132             INTERNET_ASYNC_RESULT *iar = (INTERNET_ASYNC_RESULT *)lpvStatusInformation;
133             ok(dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT),
134                 "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %ld\n",
135                 dwStatusInformationLength);
136             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%ld} %ld\n",
137                 GetCurrentThreadId(), hInternet, dwContext,
138                 iar->dwResult,iar->dwError,dwStatusInformationLength);
139             SetEvent(hCompleteEvent);
140             break;
141         }
142         case INTERNET_STATUS_REDIRECT:
143             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %ld\n",
144                 GetCurrentThreadId(), hInternet, dwContext,
145                 (LPCSTR)lpvStatusInformation, dwStatusInformationLength);
146             break;
147         case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
148             trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %ld\n",
149                 GetCurrentThreadId(), hInternet, dwContext,
150                 lpvStatusInformation, dwStatusInformationLength);
151             break;
152         default:
153             trace("%04lx:Callback %p 0x%lx %ld %p %ld\n",
154                 GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus,
155                 lpvStatusInformation, dwStatusInformationLength);
156     }
157 }
158
159 static void InternetReadFile_test(int flags)
160 {
161     DWORD rc;
162     CHAR buffer[4000];
163     DWORD length;
164     DWORD out;
165     const char *types[2] = { "*", NULL };
166     HINTERNET hi, hic = 0, hor = 0;
167
168     hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
169
170     trace("Starting InternetReadFile test with flags 0x%x\n",flags);
171
172     trace("InternetOpenA <--\n");
173     hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
174     ok((hi != 0x0),"InternetOpen failed with error %ld\n", GetLastError());
175     trace("InternetOpenA -->\n");
176
177     if (hi == 0x0) goto abort;
178
179     InternetSetStatusCallback(hi,&callback);
180
181     trace("InternetConnectA <--\n");
182     hic=InternetConnectA(hi, "www.winehq.org", INTERNET_INVALID_PORT_NUMBER,
183                          NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
184     ok((hic != 0x0),"InternetConnect failed with error %ld\n", GetLastError());
185     trace("InternetConnectA -->\n");
186
187     if (hic == 0x0) goto abort;
188
189     trace("HttpOpenRequestA <--\n");
190     hor = HttpOpenRequestA(hic, "GET", "/about/", NULL, NULL, types,
191                            INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
192                            0xdeadbead);
193     if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
194         /*
195          * If the internet name can't be resolved we are probably behind
196          * a firewall or in some other way not directly connected to the
197          * Internet. Not enough reason to fail the test. Just ignore and
198          * abort.
199          */
200     } else  {
201         ok((hor != 0x0),"HttpOpenRequest failed with error %ld\n", GetLastError());
202     }
203     trace("HttpOpenRequestA -->\n");
204
205     if (hor == 0x0) goto abort;
206
207     trace("HttpSendRequestA -->\n");
208     SetLastError(0xdeadbeef);
209     rc = HttpSendRequestA(hor, "", -1, NULL, 0);
210     if (flags & INTERNET_FLAG_ASYNC)
211         ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
212             "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
213     else
214         ok((rc != 0) || GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED,
215            "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
216     trace("HttpSendRequestA <--\n");
217
218     if (flags & INTERNET_FLAG_ASYNC)
219         WaitForSingleObject(hCompleteEvent, INFINITE);
220
221     length = 4;
222     rc = InternetQueryOptionA(hor,INTERNET_OPTION_REQUEST_FLAGS,&out,&length);
223     trace("Option 0x17 -> %li  %li\n",rc,out);
224
225     length = 100;
226     rc = InternetQueryOptionA(hor,INTERNET_OPTION_URL,buffer,&length);
227     trace("Option 0x22 -> %li  %s\n",rc,buffer);
228
229     length = 4000;
230     rc = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length,0x0);
231     buffer[length]=0;
232     trace("Option 0x16 -> %li  %s\n",rc,buffer);
233
234     length = 4000;
235     rc = InternetQueryOptionA(hor,INTERNET_OPTION_URL,buffer,&length);
236     buffer[length]=0;
237     trace("Option 0x22 -> %li  %s\n",rc,buffer);
238
239     length = 16;
240     rc = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
241     trace("Option 0x5 -> %li  %s  (%li)\n",rc,buffer,GetLastError());
242
243     length = 100;
244     rc = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
245     buffer[length]=0;
246     trace("Option 0x1 -> %li  %s\n",rc,buffer);
247
248     SetLastError(0xdeadbeef);
249     rc = InternetReadFile(NULL, buffer, 100, &length);
250     ok(!rc, "InternetReadFile should have failed\n");
251     ok(GetLastError() == ERROR_INVALID_HANDLE,
252         "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %ld\n",
253         GetLastError());
254
255     length = 100;
256     trace("Entering Query loop\n");
257
258     while (length)
259     {
260         rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
261         ok(!(rc == 0 && length != 0),"InternetQueryDataAvailable failed\n");
262
263         if (length)
264         {
265             char *buffer;
266             buffer = HeapAlloc(GetProcessHeap(),0,length+1);
267
268             rc = InternetReadFile(hor,buffer,length,&length);
269
270             buffer[length]=0;
271
272             trace("ReadFile -> %li %li\n",rc,length);
273
274             HeapFree(GetProcessHeap(),0,buffer);
275         }
276     }
277 abort:
278     if (hor != 0x0) {
279         SetLastError(0xdeadbeef);
280         rc = InternetCloseHandle(hor);
281         ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
282         SetLastError(0xdeadbeef);
283         rc = InternetCloseHandle(hor);
284         ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
285         ok (GetLastError() == ERROR_INVALID_HANDLE,
286             "Double close of handle should have set ERROR_INVALID_HANDLE instead of %ld\n",
287             GetLastError());
288     }
289     if (hic != 0x0) {
290         rc = InternetCloseHandle(hic);
291         ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
292     }
293     if (hi != 0x0) {
294       rc = InternetCloseHandle(hi);
295       ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
296       if (flags & INTERNET_FLAG_ASYNC)
297           Sleep(100);
298     }
299     CloseHandle(hCompleteEvent);
300 }
301
302 static void InternetReadFileExA_test(int flags)
303 {
304     DWORD rc;
305     DWORD length;
306     const char *types[2] = { "*", NULL };
307     HINTERNET hi, hic = 0, hor = 0;
308     INTERNET_BUFFERS inetbuffers;
309
310     hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
311
312     trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
313
314     trace("InternetOpenA <--\n");
315     hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
316     ok((hi != 0x0),"InternetOpen failed with error %ld\n", GetLastError());
317     trace("InternetOpenA -->\n");
318
319     if (hi == 0x0) goto abort;
320
321     InternetSetStatusCallback(hi,&callback);
322
323     trace("InternetConnectA <--\n");
324     hic=InternetConnectA(hi, "www.winehq.org", INTERNET_INVALID_PORT_NUMBER,
325                          NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
326     ok((hic != 0x0),"InternetConnect failed with error %ld\n", GetLastError());
327     trace("InternetConnectA -->\n");
328
329     if (hic == 0x0) goto abort;
330
331     trace("HttpOpenRequestA <--\n");
332     hor = HttpOpenRequestA(hic, "GET", "/about/", NULL, NULL, types,
333                            INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
334                            0xdeadbead);
335     if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
336         /*
337          * If the internet name can't be resolved we are probably behind
338          * a firewall or in some other way not directly connected to the
339          * Internet. Not enough reason to fail the test. Just ignore and
340          * abort.
341          */
342     } else  {
343         ok((hor != 0x0),"HttpOpenRequest failed with error %ld\n", GetLastError());
344     }
345     trace("HttpOpenRequestA -->\n");
346
347     if (hor == 0x0) goto abort;
348
349     trace("HttpSendRequestA -->\n");
350     SetLastError(0xdeadbeef);
351     rc = HttpSendRequestA(hor, "", -1, NULL, 0);
352     if (flags & INTERNET_FLAG_ASYNC)
353         ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
354             "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
355     else
356         ok((rc != 0) || GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED,
357            "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
358     trace("HttpSendRequestA <--\n");
359
360     if (!rc && (GetLastError() == ERROR_IO_PENDING))
361         WaitForSingleObject(hCompleteEvent, INFINITE);
362
363     /* tests invalid dwStructSize */
364     inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS)+1;
365     inetbuffers.lpcszHeader = NULL;
366     inetbuffers.dwHeadersLength = 0;
367     inetbuffers.dwBufferLength = 10;
368     inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, 10);
369     inetbuffers.dwOffsetHigh = 1234;
370     inetbuffers.dwOffsetLow = 5678;
371     rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
372     ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER),
373         "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %ld\n",
374         rc ? "TRUE" : "FALSE", GetLastError());
375     HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
376
377     /* tests to see whether lpcszHeader is used - it isn't */
378     inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
379     inetbuffers.lpcszHeader = (LPCTSTR)0xdeadbeef;
380     inetbuffers.dwHeadersLength = 255;
381     inetbuffers.dwBufferLength = 0;
382     inetbuffers.lpvBuffer = NULL;
383     inetbuffers.dwOffsetHigh = 1234;
384     inetbuffers.dwOffsetLow = 5678;
385     rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
386     ok(rc, "InternetReadFileEx failed with error %ld\n", GetLastError());
387
388     rc = InternetReadFileEx(NULL, &inetbuffers, 0, 0xdeadcafe);
389     ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE),
390         "InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %ld\n",
391         rc ? "TRUE" : "FALSE", GetLastError());
392
393     length = 0;
394     trace("Entering Query loop\n");
395
396     while (TRUE)
397     {
398         inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
399         inetbuffers.dwBufferLength = 1024;
400         inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, inetbuffers.dwBufferLength+1);
401         inetbuffers.dwOffsetHigh = 1234;
402         inetbuffers.dwOffsetLow = 5678;
403
404         rc = InternetReadFileExA(hor, &inetbuffers, IRF_ASYNC | IRF_USE_CONTEXT, 0xcafebabe);
405         if (!rc)
406         {
407             if (GetLastError() == ERROR_IO_PENDING)
408             {
409                 trace("InternetReadFileEx -> PENDING\n");
410                 WaitForSingleObject(hCompleteEvent, INFINITE);
411             }
412             else
413             {
414                 trace("InternetReadFileEx -> FAILED %ld\n", GetLastError());
415                 break;
416             }
417         }
418         else
419             trace("InternetReadFileEx -> SUCCEEDED\n");
420
421         trace("read %li bytes\n", inetbuffers.dwBufferLength);
422         ((char *)inetbuffers.lpvBuffer)[inetbuffers.dwBufferLength] = '\0';
423
424         ok(inetbuffers.dwOffsetHigh == 1234 && inetbuffers.dwOffsetLow == 5678,
425             "InternetReadFileEx sets offsets to 0x%lx%08lx\n",
426             inetbuffers.dwOffsetHigh, inetbuffers.dwOffsetLow);
427
428         HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
429
430         if (!inetbuffers.dwBufferLength)
431             break;
432
433         length += inetbuffers.dwBufferLength;
434     }
435     trace("Finished. Read %ld bytes\n", length);
436
437 abort:
438     if (hor) {
439         rc = InternetCloseHandle(hor);
440         ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
441         rc = InternetCloseHandle(hor);
442         ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
443     }
444     if (hic) {
445         rc = InternetCloseHandle(hic);
446         ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
447     }
448     if (hi) {
449       rc = InternetCloseHandle(hi);
450       ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
451       if (flags & INTERNET_FLAG_ASYNC)
452           Sleep(100);
453     }
454     CloseHandle(hCompleteEvent);
455 }
456
457 static void InternetOpenUrlA_test(void)
458 {
459   HINTERNET myhinternet, myhttp;
460   char buffer[0x400];
461   DWORD size, readbytes, totalbytes=0;
462   BOOL ret;
463   
464   myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
465   ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
466   size = 0x400;
467   ret = InternetCanonicalizeUrl(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
468   ok( ret, "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
469
470   SetLastError(0);
471   myhttp = InternetOpenUrl(myhinternet, TEST_URL, 0, 0,
472                            INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
473   if (GetLastError() == 12007)
474     return; /* WinXP returns this when not connected to the net */
475   ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
476   ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
477   ok( ret, "InternetReadFile failed, error %lx\n",GetLastError());
478   totalbytes += readbytes;
479   while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
480     totalbytes += readbytes;
481   trace("read 0x%08lx bytes\n",totalbytes);
482 }
483
484 static void InternetTimeFromSystemTimeA_test(void)
485 {
486     BOOL ret;
487     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
488     char string[INTERNET_RFC1123_BUFSIZE];
489     static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
490
491     ret = InternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
492     ok( ret, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
493
494     ok( !memcmp( string, expect, sizeof(expect) ),
495         "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
496 }
497
498 static void InternetTimeFromSystemTimeW_test(void)
499 {
500     BOOL ret;
501     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
502     WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
503     static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
504                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
505
506     ret = InternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
507     ok( ret, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
508
509     ok( !memcmp( string, expect, sizeof(expect) ),
510         "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
511 }
512
513 static void InternetTimeToSystemTimeA_test(void)
514 {
515     BOOL ret;
516     SYSTEMTIME time;
517     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
518     static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
519     static const char string2[] = " fri 7 jan 2005 12 06 35";
520
521     ret = InternetTimeToSystemTimeA( string, &time, 0 );
522     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
523     ok( !memcmp( &time, &expect, sizeof(expect) ),
524         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
525
526     ret = InternetTimeToSystemTimeA( string2, &time, 0 );
527     ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
528     ok( !memcmp( &time, &expect, sizeof(expect) ),
529         "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
530 }
531
532 static void InternetTimeToSystemTimeW_test(void)
533 {
534     BOOL ret;
535     SYSTEMTIME time;
536     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
537     static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
538                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
539     static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
540                                      '1','2',' ','0','6',' ','3','5',0 };
541     static const WCHAR string3[] = { 'F','r',0 };
542
543     ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
544     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
545
546     ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
547     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
548
549     ret = InternetTimeToSystemTimeW( string, NULL, 0 );
550     ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
551
552     ret = InternetTimeToSystemTimeW( string, &time, 1 );
553     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
554
555     ret = InternetTimeToSystemTimeW( string, &time, 0 );
556     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
557     ok( !memcmp( &time, &expect, sizeof(expect) ),
558         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
559
560     ret = InternetTimeToSystemTimeW( string2, &time, 0 );
561     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
562     ok( !memcmp( &time, &expect, sizeof(expect) ),
563         "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
564
565     ret = InternetTimeToSystemTimeW( string3, &time, 0 );
566     ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
567 }
568
569 static void HttpSendRequestEx_test(void)
570 {
571     HINTERNET hSession;
572     HINTERNET hConnect;
573     HINTERNET hRequest;
574
575     INTERNET_BUFFERS BufferIn;
576     DWORD dwBytesWritten;
577     DWORD dwBytesRead;
578     CHAR szBuffer[256];
579     int i;
580     BOOL ret;
581
582     static const char szPostData[] = "mode=Test";
583     static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
584     
585     hSession = InternetOpen("Wine Regression Test",
586             INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
587     ok( hSession != NULL ,"Unable to open Internet session\n");
588     hConnect = InternetConnect(hSession, "crossover.codeweavers.com",
589             INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
590             0);
591     ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
592     hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php",
593             NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
594     ok( hRequest != NULL, "Failed to open request handle\n");
595
596
597     BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS);
598     BufferIn.Next = (LPINTERNET_BUFFERS)0xdeadcab;
599     BufferIn.lpcszHeader = szContentType;
600     BufferIn.dwHeadersLength = sizeof(szContentType);
601     BufferIn.dwHeadersTotal = sizeof(szContentType);
602     BufferIn.lpvBuffer = (LPVOID)szPostData;
603     BufferIn.dwBufferLength = 3;
604     BufferIn.dwBufferTotal = sizeof(szPostData)-1;
605     BufferIn.dwOffsetLow = 0;
606     BufferIn.dwOffsetHigh = 0;
607
608     ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
609     ok(ret, "HttpSendRequestEx Failed with error %ld\n", GetLastError());
610
611     for (i = 3; szPostData[i]; i++)
612         ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
613                 "InternetWriteFile failed\n");
614
615     ok(HttpEndRequest(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
616
617     ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
618             "Unable to read response\n");
619     szBuffer[dwBytesRead] = 0;
620
621     ok(dwBytesRead == 13,"Read %lu bytes instead of 13\n",dwBytesRead);
622     ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0,"Got string %s\n",szBuffer);
623
624     ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
625     ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
626     ok(InternetCloseHandle(hSession), "Close session handle failed\n");
627 }
628
629 static void HttpHeaders_test(void)
630 {
631     HINTERNET hSession;
632     HINTERNET hConnect;
633     HINTERNET hRequest;
634     CHAR      buffer[256];
635     DWORD     len = 256;
636     DWORD     index = 0;
637
638     hSession = InternetOpen("Wine Regression Test",
639             INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
640     ok( hSession != NULL ,"Unable to open Internet session\n");
641     hConnect = InternetConnect(hSession, "crossover.codeweavers.com",
642             INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
643             0);
644     ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
645     hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php",
646             NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
647     ok( hRequest != NULL, "Failed to open request handle\n");
648
649     index = 0;
650     len = sizeof(buffer);
651     strcpy(buffer,"Warning");
652     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
653                buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
654     
655     ok(HttpAddRequestHeaders(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
656             "Failed to add new header\n");
657
658     index = 0;
659     len = sizeof(buffer);
660     strcpy(buffer,"Warning");
661     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
662                 buffer,&len,&index),"Unable to query header\n");
663     ok(index == 1, "Index was not incremented\n");
664     ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
665     len = sizeof(buffer);
666     strcpy(buffer,"Warning");
667     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
668                 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
669
670     ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
671             "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
672
673     index = 0;
674     len = sizeof(buffer);
675     strcpy(buffer,"Warning");
676     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
677                 buffer,&len,&index),"Unable to query header\n");
678     ok(index == 1, "Index was not incremented\n");
679     ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
680     len = sizeof(buffer);
681     strcpy(buffer,"Warning");
682     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
683                 buffer,&len,&index),"Failed to get second header\n");
684     ok(index == 2, "Index was not incremented\n");
685     ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
686     len = sizeof(buffer);
687     strcpy(buffer,"Warning");
688     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
689                 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
690
691     ok(HttpAddRequestHeaders(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
692
693     index = 0;
694     len = sizeof(buffer);
695     strcpy(buffer,"Warning");
696     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
697                 buffer,&len,&index),"Unable to query header\n");
698     ok(index == 1, "Index was not incremented\n");
699     ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
700     len = sizeof(buffer);
701     strcpy(buffer,"Warning");
702     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
703                 buffer,&len,&index),"Failed to get second header\n");
704     ok(index == 2, "Index was not incremented\n");
705     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
706     len = sizeof(buffer);
707     strcpy(buffer,"Warning");
708     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
709                 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
710     
711     ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
712
713     index = 0;
714     len = sizeof(buffer);
715     strcpy(buffer,"Warning");
716     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
717                 buffer,&len,&index),"Unable to query header\n");
718     ok(index == 1, "Index was not incremented\n");
719     ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
720     len = sizeof(buffer);
721     strcpy(buffer,"Warning");
722     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
723                 buffer,&len,&index),"Failed to get second header\n");
724     ok(index == 2, "Index was not incremented\n");
725     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
726     len = sizeof(buffer);
727     strcpy(buffer,"Warning");
728     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
729                 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
730
731     ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
732
733     index = 0;
734     len = sizeof(buffer);
735     strcpy(buffer,"Warning");
736     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
737                 buffer,&len,&index),"Unable to query header\n");
738     ok(index == 1, "Index was not incremented\n");
739     ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
740     len = sizeof(buffer);
741     strcpy(buffer,"Warning");
742     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
743     ok(index == 2, "Index was not incremented\n");
744     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
745     len = sizeof(buffer);
746     strcpy(buffer,"Warning");
747     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
748
749     ok(HttpAddRequestHeaders(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
750
751     index = 0;
752     len = sizeof(buffer);
753     strcpy(buffer,"Warning");
754     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
755     ok(index == 1, "Index was not incremented\n");
756     ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
757     len = sizeof(buffer);
758     strcpy(buffer,"Warning");
759     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
760     ok(index == 2, "Index was not incremented\n");
761     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
762     len = sizeof(buffer);
763     strcpy(buffer,"Warning");
764     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
765
766     ok(HttpAddRequestHeaders(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
767
768     index = 0;
769     len = sizeof(buffer);
770     strcpy(buffer,"Warning");
771     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
772     ok(index == 1, "Index was not incremented\n");
773     ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
774     len = sizeof(buffer);
775     strcpy(buffer,"Warning");
776     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
777     ok(index == 2, "Index was not incremented\n");
778     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
779     len = sizeof(buffer);
780     strcpy(buffer,"Warning");
781     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
782
783     ok(HttpAddRequestHeaders(hRequest,"Warning:test7",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE), "HTTP_ADDREQ_FLAG_ADD with HTTP_ADDREQ_FLAG_REPALCE Did not work\n");
784
785     index = 0;
786     len = sizeof(buffer);
787     strcpy(buffer,"Warning");
788     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
789     ok(index == 1, "Index was not incremented\n");
790     ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
791     len = sizeof(buffer);
792     strcpy(buffer,"Warning");
793     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
794     ok(index == 2, "Index was not incremented\n");
795     ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
796     len = sizeof(buffer);
797     strcpy(buffer,"Warning");
798     ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
799
800     
801     ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
802     ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
803     ok(InternetCloseHandle(hSession), "Close session handle failed\n");
804 }
805
806 static const char okmsg[] =
807 "HTTP/1.0 200 OK\r\n"
808 "Server: winetest\r\n"
809 "\r\n";
810
811 static const char page1[] =
812 "<HTML>\r\n"
813 "<HEAD><TITLE>wininet test page</TITLE></HEAD>\r\n"
814 "<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
815 "</HTML>\r\n\r\n";
816
817 struct server_info {
818     HANDLE hEvent;
819     int port;
820 };
821
822 static DWORD CALLBACK server_thread(LPVOID param)
823 {
824     struct server_info *si = param;
825     int r, s, c, i;
826     struct sockaddr_in sa;
827     char buffer[0x100];
828     WSADATA wsaData;
829
830     WSAStartup(MAKEWORD(1,1), &wsaData);
831
832     s = socket(AF_INET, SOCK_STREAM, 0);
833     if (s<0)
834         return FALSE;
835
836     memset(&sa, 0, sizeof sa);
837     sa.sin_family = AF_INET;
838     sa.sin_port = htons(si->port);
839     sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
840
841     r = bind(s, (struct sockaddr*) &sa, sizeof sa);
842     if (r<0)
843         return 1;
844
845     listen(s, 1);
846
847     SetEvent(si->hEvent);
848
849     c = accept(s, NULL, NULL);
850
851     memset(buffer, 0, sizeof buffer);
852     for(i=0; i<(sizeof buffer-1); i++)
853     {
854         r = recv(c, &buffer[i], 1, 0);
855         if (r != 1)
856             break;
857         if (i<4) continue;
858         if (buffer[i-2] == '\n' && buffer[i] == '\n' &&
859             buffer[i-3] == '\r' && buffer[i-1] == '\r')
860             break;
861     }
862
863     send(c, okmsg, sizeof okmsg-1, 0);
864     send(c, page1, sizeof page1-1, 0);
865
866     closesocket(c);
867     closesocket(s);
868
869     return 0;
870 }
871
872 static void test_http_connection(void)
873 {
874     struct server_info si;
875     HINTERNET hi, hc, hr;
876     HANDLE hThread;
877     DWORD id = 0, r, count;
878     char buffer[0x100];
879
880     si.hEvent = CreateEvent(NULL, 0, 0, NULL);
881     si.port = 7531;
882
883     hThread = CreateThread(NULL, 0, server_thread, (LPVOID) &si, 0, &id);
884     ok( hThread != NULL, "create thread failed\n");
885
886     r = WaitForSingleObject(si.hEvent, 3000);
887     ok (r == WAIT_OBJECT_0, "failed to start wininet test server\n");
888     if (r != WAIT_OBJECT_0)
889         return;
890
891     hi = InternetOpen(NULL, 0, NULL, NULL, 0);
892     ok(hi != NULL, "open failed\n");
893
894     hc = InternetConnect(hi, "localhost", si.port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
895     ok(hc != NULL, "connect failed\n");
896
897     hr = HttpOpenRequest(hc, NULL, "/test", NULL, NULL, NULL, 0, 0);
898     ok(hr != NULL, "HttpOpenRequest failed\n");
899
900     r = HttpSendRequest(hr, NULL, 0, NULL, 0);
901     ok(r, "HttpSendRequest failed\n");
902
903     count = 0;
904     memset(buffer, 0, sizeof buffer);
905     r = InternetReadFile(hr, buffer, sizeof buffer, &count);
906     ok(r, "InternetReadFile failed\n");
907     ok(count == sizeof page1 - 1, "count was wrong\n");
908     ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
909
910     InternetCloseHandle(hr);
911     InternetCloseHandle(hc);
912     InternetCloseHandle(hi);
913
914     r = WaitForSingleObject(hThread, 3000);
915     ok( r == WAIT_OBJECT_0, "thread wait failed\n");
916     CloseHandle(hThread);
917 }
918
919 START_TEST(http)
920 {
921     InternetReadFile_test(INTERNET_FLAG_ASYNC);
922     InternetReadFile_test(0);
923     InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
924     InternetOpenUrlA_test();
925     InternetTimeFromSystemTimeA_test();
926     InternetTimeFromSystemTimeW_test();
927     InternetTimeToSystemTimeA_test();
928     InternetTimeToSystemTimeW_test();
929     HttpSendRequestEx_test();
930     HttpHeaders_test();
931     test_http_connection();
932 }