4 * Copyright 2002 Aric Stewart
5 * Copyright 2004 Mike McCormack
6 * Copyright 2005 Hans Leidekker
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.
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.
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
31 #include "wine/test.h"
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"
42 #define CREATE_URL1 "http://username:password@www.winehq.org/site/about"
43 #define CREATE_URL2 "http://username@www.winehq.org/site/about"
44 #define CREATE_URL3 "http://username:"
45 #define CREATE_URL4 "http://www.winehq.org/site/about"
46 #define CREATE_URL5 "http://"
47 #define CREATE_URL6 "nhttp://username:password@www.winehq.org:80/site/about"
48 #define CREATE_URL7 "http://username:password@www.winehq.org:42/site/about"
49 #define CREATE_URL8 "https://username:password@www.winehq.org/site/about"
50 #define CREATE_URL9 "about:blank"
51 #define CREATE_URL10 "about://host/blank"
52 #define CREATE_URL11 "about:"
53 #define CREATE_URL12 "http://www.winehq.org:65535"
55 static HANDLE hCompleteEvent;
57 static VOID WINAPI callback(
60 DWORD dwInternetStatus,
61 LPVOID lpvStatusInformation,
62 DWORD dwStatusInformationLength
65 switch (dwInternetStatus)
67 case INTERNET_STATUS_RESOLVING_NAME:
68 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %ld\n",
69 GetCurrentThreadId(), hInternet, dwContext,
70 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
72 case INTERNET_STATUS_NAME_RESOLVED:
73 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %ld\n",
74 GetCurrentThreadId(), hInternet, dwContext,
75 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
77 case INTERNET_STATUS_CONNECTING_TO_SERVER:
78 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %ld\n",
79 GetCurrentThreadId(), hInternet, dwContext,
80 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
82 case INTERNET_STATUS_CONNECTED_TO_SERVER:
83 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %ld\n",
84 GetCurrentThreadId(), hInternet, dwContext,
85 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
87 case INTERNET_STATUS_SENDING_REQUEST:
88 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %ld\n",
89 GetCurrentThreadId(), hInternet, dwContext,
90 lpvStatusInformation,dwStatusInformationLength);
92 case INTERNET_STATUS_REQUEST_SENT:
93 ok(dwStatusInformationLength == sizeof(DWORD),
94 "info length should be sizeof(DWORD) instead of %ld\n",
95 dwStatusInformationLength);
96 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%lx %ld\n",
97 GetCurrentThreadId(), hInternet, dwContext,
98 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
100 case INTERNET_STATUS_RECEIVING_RESPONSE:
101 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %ld\n",
102 GetCurrentThreadId(), hInternet, dwContext,
103 lpvStatusInformation,dwStatusInformationLength);
105 case INTERNET_STATUS_RESPONSE_RECEIVED:
106 ok(dwStatusInformationLength == sizeof(DWORD),
107 "info length should be sizeof(DWORD) instead of %ld\n",
108 dwStatusInformationLength);
109 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%lx %ld\n",
110 GetCurrentThreadId(), hInternet, dwContext,
111 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
113 case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
114 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %ld\n",
115 GetCurrentThreadId(), hInternet,dwContext,
116 lpvStatusInformation,dwStatusInformationLength);
118 case INTERNET_STATUS_PREFETCH:
119 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %ld\n",
120 GetCurrentThreadId(), hInternet, dwContext,
121 lpvStatusInformation,dwStatusInformationLength);
123 case INTERNET_STATUS_CLOSING_CONNECTION:
124 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %ld\n",
125 GetCurrentThreadId(), hInternet, dwContext,
126 lpvStatusInformation,dwStatusInformationLength);
128 case INTERNET_STATUS_CONNECTION_CLOSED:
129 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %ld\n",
130 GetCurrentThreadId(), hInternet, dwContext,
131 lpvStatusInformation,dwStatusInformationLength);
133 case INTERNET_STATUS_HANDLE_CREATED:
134 ok(dwStatusInformationLength == sizeof(HINTERNET),
135 "info length should be sizeof(HINTERNET) instead of %ld\n",
136 dwStatusInformationLength);
137 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %ld\n",
138 GetCurrentThreadId(), hInternet, dwContext,
139 *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength);
141 case INTERNET_STATUS_HANDLE_CLOSING:
142 ok(dwStatusInformationLength == sizeof(HINTERNET),
143 "info length should be sizeof(HINTERNET) instead of %ld\n",
144 dwStatusInformationLength);
145 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %ld\n",
146 GetCurrentThreadId(), hInternet, dwContext,
147 *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength);
149 case INTERNET_STATUS_REQUEST_COMPLETE:
151 INTERNET_ASYNC_RESULT *iar = (INTERNET_ASYNC_RESULT *)lpvStatusInformation;
152 ok(dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT),
153 "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %ld\n",
154 dwStatusInformationLength);
155 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%ld} %ld\n",
156 GetCurrentThreadId(), hInternet, dwContext,
157 iar->dwResult,iar->dwError,dwStatusInformationLength);
158 SetEvent(hCompleteEvent);
161 case INTERNET_STATUS_REDIRECT:
162 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %ld\n",
163 GetCurrentThreadId(), hInternet, dwContext,
164 (LPCSTR)lpvStatusInformation, dwStatusInformationLength);
166 case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
167 trace("%04lx:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %ld\n",
168 GetCurrentThreadId(), hInternet, dwContext,
169 lpvStatusInformation, dwStatusInformationLength);
172 trace("%04lx:Callback %p 0x%lx %ld %p %ld\n",
173 GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus,
174 lpvStatusInformation, dwStatusInformationLength);
178 static void InternetReadFile_test(int flags)
184 const char *types[2] = { "*", NULL };
185 HINTERNET hi, hic = 0, hor = 0;
187 hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
189 trace("Starting InternetReadFile test with flags 0x%x\n",flags);
191 trace("InternetOpenA <--\n");
192 hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
193 ok((hi != 0x0),"InternetOpen failed with error %ld\n", GetLastError());
194 trace("InternetOpenA -->\n");
196 if (hi == 0x0) goto abort;
198 InternetSetStatusCallback(hi,&callback);
200 trace("InternetConnectA <--\n");
201 hic=InternetConnectA(hi, "www.winehq.org", INTERNET_INVALID_PORT_NUMBER,
202 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
203 ok((hic != 0x0),"InternetConnect failed with error %ld\n", GetLastError());
204 trace("InternetConnectA -->\n");
206 if (hic == 0x0) goto abort;
208 trace("HttpOpenRequestA <--\n");
209 hor = HttpOpenRequestA(hic, "GET", "/about/", NULL, NULL, types,
210 INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
212 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
214 * If the internet name can't be resolved we are probably behind
215 * a firewall or in some other way not directly connected to the
216 * Internet. Not enough reason to fail the test. Just ignore and
220 ok((hor != 0x0),"HttpOpenRequest failed with error %ld\n", GetLastError());
222 trace("HttpOpenRequestA -->\n");
224 if (hor == 0x0) goto abort;
226 trace("HttpSendRequestA -->\n");
227 SetLastError(0xdeadbeef);
228 rc = HttpSendRequestA(hor, "", -1, NULL, 0);
229 if (flags & INTERNET_FLAG_ASYNC)
230 ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
231 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
233 ok((rc != 0) || GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED,
234 "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
235 trace("HttpSendRequestA <--\n");
237 if (flags & INTERNET_FLAG_ASYNC)
238 WaitForSingleObject(hCompleteEvent, INFINITE);
241 rc = InternetQueryOptionA(hor,INTERNET_OPTION_REQUEST_FLAGS,&out,&length);
242 trace("Option 0x17 -> %li %li\n",rc,out);
245 rc = InternetQueryOptionA(hor,INTERNET_OPTION_URL,buffer,&length);
246 trace("Option 0x22 -> %li %s\n",rc,buffer);
249 rc = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length,0x0);
251 trace("Option 0x16 -> %li %s\n",rc,buffer);
254 rc = InternetQueryOptionA(hor,INTERNET_OPTION_URL,buffer,&length);
256 trace("Option 0x22 -> %li %s\n",rc,buffer);
259 rc = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
260 trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
263 rc = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
265 trace("Option 0x1 -> %li %s\n",rc,buffer);
267 SetLastError(0xdeadbeef);
268 rc = InternetReadFile(NULL, buffer, 100, &length);
269 ok(!rc, "InternetReadFile should have failed\n");
270 ok(GetLastError() == ERROR_INVALID_HANDLE,
271 "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %ld\n",
275 trace("Entering Query loop\n");
279 rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
280 ok(!(rc == 0 && length != 0),"InternetQueryDataAvailable failed\n");
285 buffer = HeapAlloc(GetProcessHeap(),0,length+1);
287 rc = InternetReadFile(hor,buffer,length,&length);
291 trace("ReadFile -> %li %li\n",rc,length);
293 HeapFree(GetProcessHeap(),0,buffer);
298 SetLastError(0xdeadbeef);
299 rc = InternetCloseHandle(hor);
300 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
301 SetLastError(0xdeadbeef);
302 rc = InternetCloseHandle(hor);
303 ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
304 ok (GetLastError() == ERROR_INVALID_HANDLE,
305 "Double close of handle should have set ERROR_INVALID_HANDLE instead of %ld\n",
309 rc = InternetCloseHandle(hic);
310 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
313 rc = InternetCloseHandle(hi);
314 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
315 if (flags & INTERNET_FLAG_ASYNC)
318 CloseHandle(hCompleteEvent);
321 static void InternetReadFileExA_test(int flags)
325 const char *types[2] = { "*", NULL };
326 HINTERNET hi, hic = 0, hor = 0;
327 INTERNET_BUFFERS inetbuffers;
329 hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
331 trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
333 trace("InternetOpenA <--\n");
334 hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags);
335 ok((hi != 0x0),"InternetOpen failed with error %ld\n", GetLastError());
336 trace("InternetOpenA -->\n");
338 if (hi == 0x0) goto abort;
340 InternetSetStatusCallback(hi,&callback);
342 trace("InternetConnectA <--\n");
343 hic=InternetConnectA(hi, "www.winehq.org", INTERNET_INVALID_PORT_NUMBER,
344 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
345 ok((hic != 0x0),"InternetConnect failed with error %ld\n", GetLastError());
346 trace("InternetConnectA -->\n");
348 if (hic == 0x0) goto abort;
350 trace("HttpOpenRequestA <--\n");
351 hor = HttpOpenRequestA(hic, "GET", "/about/", NULL, NULL, types,
352 INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE,
354 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
356 * If the internet name can't be resolved we are probably behind
357 * a firewall or in some other way not directly connected to the
358 * Internet. Not enough reason to fail the test. Just ignore and
362 ok((hor != 0x0),"HttpOpenRequest failed with error %ld\n", GetLastError());
364 trace("HttpOpenRequestA -->\n");
366 if (hor == 0x0) goto abort;
368 trace("HttpSendRequestA -->\n");
369 SetLastError(0xdeadbeef);
370 rc = HttpSendRequestA(hor, "", -1, NULL, 0);
371 if (flags & INTERNET_FLAG_ASYNC)
372 ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
373 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
375 ok((rc != 0) || GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED,
376 "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
377 trace("HttpSendRequestA <--\n");
379 if (!rc && (GetLastError() == ERROR_IO_PENDING))
380 WaitForSingleObject(hCompleteEvent, INFINITE);
382 /* tests invalid dwStructSize */
383 inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS)+1;
384 inetbuffers.lpcszHeader = NULL;
385 inetbuffers.dwHeadersLength = 0;
386 inetbuffers.dwBufferLength = 10;
387 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, 10);
388 inetbuffers.dwOffsetHigh = 1234;
389 inetbuffers.dwOffsetLow = 5678;
390 rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
391 ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER),
392 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %ld\n",
393 rc ? "TRUE" : "FALSE", GetLastError());
394 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
396 /* tests to see whether lpcszHeader is used - it isn't */
397 inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
398 inetbuffers.lpcszHeader = (LPCTSTR)0xdeadbeef;
399 inetbuffers.dwHeadersLength = 255;
400 inetbuffers.dwBufferLength = 0;
401 inetbuffers.lpvBuffer = NULL;
402 inetbuffers.dwOffsetHigh = 1234;
403 inetbuffers.dwOffsetLow = 5678;
404 rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
405 ok(rc, "InternetReadFileEx failed with error %ld\n", GetLastError());
407 rc = InternetReadFileEx(NULL, &inetbuffers, 0, 0xdeadcafe);
408 ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE),
409 "InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %ld\n",
410 rc ? "TRUE" : "FALSE", GetLastError());
413 trace("Entering Query loop\n");
417 inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
418 inetbuffers.dwBufferLength = 1024;
419 inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, inetbuffers.dwBufferLength+1);
420 inetbuffers.dwOffsetHigh = 1234;
421 inetbuffers.dwOffsetLow = 5678;
423 rc = InternetReadFileExA(hor, &inetbuffers, IRF_ASYNC | IRF_USE_CONTEXT, 0xcafebabe);
426 if (GetLastError() == ERROR_IO_PENDING)
428 trace("InternetReadFileEx -> PENDING\n");
429 WaitForSingleObject(hCompleteEvent, INFINITE);
433 trace("InternetReadFileEx -> FAILED %ld\n", GetLastError());
438 trace("InternetReadFileEx -> SUCCEEDED\n");
440 trace("read %li bytes\n", inetbuffers.dwBufferLength);
441 ((char *)inetbuffers.lpvBuffer)[inetbuffers.dwBufferLength] = '\0';
443 ok(inetbuffers.dwOffsetHigh == 1234 && inetbuffers.dwOffsetLow == 5678,
444 "InternetReadFileEx sets offsets to 0x%lx%08lx\n",
445 inetbuffers.dwOffsetHigh, inetbuffers.dwOffsetLow);
447 HeapFree(GetProcessHeap(), 0, inetbuffers.lpvBuffer);
449 if (!inetbuffers.dwBufferLength)
452 length += inetbuffers.dwBufferLength;
454 trace("Finished. Read %ld bytes\n", length);
458 rc = InternetCloseHandle(hor);
459 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
460 rc = InternetCloseHandle(hor);
461 ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
464 rc = InternetCloseHandle(hic);
465 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
468 rc = InternetCloseHandle(hi);
469 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
470 if (flags & INTERNET_FLAG_ASYNC)
473 CloseHandle(hCompleteEvent);
476 static void InternetOpenUrlA_test(void)
478 HINTERNET myhinternet, myhttp;
480 URL_COMPONENTSA urlComponents;
481 char protocol[32], hostName[1024], userName[1024];
482 char password[1024], extra[1024], path[1024];
483 DWORD size, readbytes, totalbytes=0;
486 myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
487 ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
489 ret = InternetCanonicalizeUrl(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
490 ok( ret, "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
492 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
493 urlComponents.lpszScheme = protocol;
494 urlComponents.dwSchemeLength = 32;
495 urlComponents.lpszHostName = hostName;
496 urlComponents.dwHostNameLength = 1024;
497 urlComponents.lpszUserName = userName;
498 urlComponents.dwUserNameLength = 1024;
499 urlComponents.lpszPassword = password;
500 urlComponents.dwPasswordLength = 1024;
501 urlComponents.lpszUrlPath = path;
502 urlComponents.dwUrlPathLength = 2048;
503 urlComponents.lpszExtraInfo = extra;
504 urlComponents.dwExtraInfoLength = 1024;
505 ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
506 ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
508 myhttp = InternetOpenUrl(myhinternet, TEST_URL, 0, 0,
509 INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
510 if (GetLastError() == 12007)
511 return; /* WinXP returns this when not connected to the net */
512 ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
513 ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
514 ok( ret, "InternetReadFile failed, error %lx\n",GetLastError());
515 totalbytes += readbytes;
516 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
517 totalbytes += readbytes;
518 trace("read 0x%08lx bytes\n",totalbytes);
521 static inline void copy_compsA(
522 URL_COMPONENTSA *src,
523 URL_COMPONENTSA *dst,
532 dst->dwSchemeLength = scheLen;
533 dst->dwHostNameLength = hostLen;
534 dst->dwUserNameLength = userLen;
535 dst->dwPasswordLength = passLen;
536 dst->dwUrlPathLength = pathLen;
537 dst->dwExtraInfoLength = extrLen;
538 SetLastError(0xfaceabad);
541 static inline void zero_compsA(
542 URL_COMPONENTSA *dst,
550 ZeroMemory(dst, sizeof(URL_COMPONENTSA));
551 dst->dwStructSize = sizeof(URL_COMPONENTSA);
552 dst->dwSchemeLength = scheLen;
553 dst->dwHostNameLength = hostLen;
554 dst->dwUserNameLength = userLen;
555 dst->dwPasswordLength = passLen;
556 dst->dwUrlPathLength = pathLen;
557 dst->dwExtraInfoLength = extrLen;
558 SetLastError(0xfaceabad);
561 static void InternetCrackUrl_test(void)
563 URL_COMPONENTSA urlSrc, urlComponents;
564 char protocol[32], hostName[1024], userName[1024];
565 char password[1024], extra[1024], path[1024];
569 ZeroMemory(&urlSrc, sizeof(urlSrc));
570 urlSrc.dwStructSize = sizeof(urlSrc);
571 urlSrc.lpszScheme = protocol;
572 urlSrc.lpszHostName = hostName;
573 urlSrc.lpszUserName = userName;
574 urlSrc.lpszPassword = password;
575 urlSrc.lpszUrlPath = path;
576 urlSrc.lpszExtraInfo = extra;
578 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
579 ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
580 ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
581 ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
583 /* Bug 1805: Confirm the returned lengths are correct: */
584 /* 1. When extra info split out explicitly */
585 zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
586 ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error 0x%lx\n", GetLastError());
587 ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
588 ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
589 ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
590 ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
591 ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
592 ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
594 /* 2. When extra info is not split out explicitly and is in url path */
595 zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
596 ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
597 ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
598 ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
599 ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
600 ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
602 /*3. Check for %20 */
603 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
604 ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
607 /* Tests for lpsz* members pointing to real strings while
608 * some corresponding length members are set to zero */
609 copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024);
610 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
611 ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
612 ret, GetLastError());
614 copy_compsA(&urlSrc, &urlComponents, 32, 0, 1024, 1024, 2048, 1024);
615 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
616 ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
617 ret, GetLastError());
619 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 0, 1024, 2048, 1024);
620 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
621 ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
622 ret, GetLastError());
624 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 0, 2048, 1024);
625 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
626 ok(ret==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
627 ret, GetLastError());
629 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 0, 1024);
630 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
631 GLE = GetLastError();
633 ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER),
634 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
637 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 0);
638 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
639 GLE = GetLastError();
641 ok(ret==0 && (GLE==ERROR_INVALID_HANDLE || GLE==ERROR_INSUFFICIENT_BUFFER),
642 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
645 copy_compsA(&urlSrc, &urlComponents, 0, 0, 0, 0, 0, 0);
646 ret = InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents);
647 GLE = GetLastError();
649 ok(ret==0 && GLE==ERROR_INVALID_PARAMETER,
650 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_PARAMETER)\n",
654 static void InternetCrackUrlW_test(void)
657 'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
658 'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
659 '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
661 URL_COMPONENTSW comp;
662 WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
671 memset(&comp, 0, sizeof comp);
672 comp.dwStructSize = sizeof comp;
673 comp.lpszScheme = scheme;
674 comp.dwSchemeLength = sizeof scheme;
675 comp.lpszHostName = host;
676 comp.dwHostNameLength = sizeof host;
677 comp.lpszUserName = user;
678 comp.dwUserNameLength = sizeof user;
679 comp.lpszPassword = pwd;
680 comp.dwPasswordLength = sizeof pwd;
681 comp.lpszUrlPath = urlpart;
682 comp.dwUrlPathLength = sizeof urlpart;
683 comp.lpszExtraInfo = extra;
684 comp.dwExtraInfoLength = sizeof extra;
686 r = InternetCrackUrlW(url, 0, 0, &comp );
687 ok( r, "failed to crack url\n");
688 ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
689 ok( comp.dwHostNameLength == 12, "host length wrong\n");
690 ok( comp.dwUserNameLength == 0, "user length wrong\n");
691 ok( comp.dwPasswordLength == 0, "password length wrong\n");
692 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
693 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
701 memset(&comp, 0, sizeof comp);
702 comp.dwStructSize = sizeof comp;
703 comp.lpszHostName = host;
704 comp.dwHostNameLength = sizeof host;
705 comp.lpszUrlPath = urlpart;
706 comp.dwUrlPathLength = sizeof urlpart;
708 r = InternetCrackUrlW(url, 0, 0, &comp );
709 ok( r, "failed to crack url\n");
710 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
711 ok( comp.dwHostNameLength == 12, "host length wrong\n");
712 ok( comp.dwUserNameLength == 0, "user length wrong\n");
713 ok( comp.dwPasswordLength == 0, "password length wrong\n");
714 ok( comp.dwUrlPathLength == 44, "url length wrong\n");
715 ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
723 memset(&comp, 0, sizeof comp);
724 comp.dwStructSize = sizeof comp;
725 comp.lpszHostName = host;
726 comp.dwHostNameLength = sizeof host;
727 comp.lpszUrlPath = urlpart;
728 comp.dwUrlPathLength = sizeof urlpart;
729 comp.lpszExtraInfo = NULL;
730 comp.dwExtraInfoLength = sizeof extra;
732 r = InternetCrackUrlW(url, 0, 0, &comp );
733 ok( r, "failed to crack url\n");
734 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
735 ok( comp.dwHostNameLength == 12, "host length wrong\n");
736 ok( comp.dwUserNameLength == 0, "user length wrong\n");
737 ok( comp.dwPasswordLength == 0, "password length wrong\n");
738 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
739 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
742 static void InternetTimeFromSystemTimeA_test(void)
745 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
746 char string[INTERNET_RFC1123_BUFSIZE];
747 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
749 ret = InternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
750 ok( ret, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
752 ok( !memcmp( string, expect, sizeof(expect) ),
753 "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
756 static void InternetTimeFromSystemTimeW_test(void)
759 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
760 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
761 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
762 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
764 ret = InternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
765 ok( ret, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
767 ok( !memcmp( string, expect, sizeof(expect) ),
768 "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
771 static void InternetTimeToSystemTimeA_test(void)
775 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
776 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
777 static const char string2[] = " fri 7 jan 2005 12 06 35";
779 ret = InternetTimeToSystemTimeA( string, &time, 0 );
780 ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
781 ok( !memcmp( &time, &expect, sizeof(expect) ),
782 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
784 ret = InternetTimeToSystemTimeA( string2, &time, 0 );
785 ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
786 ok( !memcmp( &time, &expect, sizeof(expect) ),
787 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
790 static void InternetTimeToSystemTimeW_test(void)
794 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
795 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
796 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
797 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
798 '1','2',' ','0','6',' ','3','5',0 };
799 static const WCHAR string3[] = { 'F','r',0 };
801 ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
802 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
804 ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
805 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
807 ret = InternetTimeToSystemTimeW( string, NULL, 0 );
808 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
810 ret = InternetTimeToSystemTimeW( string, &time, 1 );
811 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
813 ret = InternetTimeToSystemTimeW( string, &time, 0 );
814 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
815 ok( !memcmp( &time, &expect, sizeof(expect) ),
816 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
818 ret = InternetTimeToSystemTimeW( string2, &time, 0 );
819 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
820 ok( !memcmp( &time, &expect, sizeof(expect) ),
821 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
823 ret = InternetTimeToSystemTimeW( string3, &time, 0 );
824 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
827 static void fill_url_components(LPURL_COMPONENTS lpUrlComponents)
829 lpUrlComponents->dwStructSize = sizeof(URL_COMPONENTS);
830 lpUrlComponents->lpszScheme = "http";
831 lpUrlComponents->dwSchemeLength = strlen(lpUrlComponents->lpszScheme);
832 lpUrlComponents->nScheme = INTERNET_SCHEME_HTTP;
833 lpUrlComponents->lpszHostName = "www.winehq.org";
834 lpUrlComponents->dwHostNameLength = strlen(lpUrlComponents->lpszHostName);
835 lpUrlComponents->nPort = 80;
836 lpUrlComponents->lpszUserName = "username";
837 lpUrlComponents->dwUserNameLength = strlen(lpUrlComponents->lpszUserName);
838 lpUrlComponents->lpszPassword = "password";
839 lpUrlComponents->dwPasswordLength = strlen(lpUrlComponents->lpszPassword);
840 lpUrlComponents->lpszUrlPath = "/site/about";
841 lpUrlComponents->dwUrlPathLength = strlen(lpUrlComponents->lpszUrlPath);
842 lpUrlComponents->lpszExtraInfo = "";
843 lpUrlComponents->dwExtraInfoLength = strlen(lpUrlComponents->lpszExtraInfo);
846 static void InternetCreateUrlA_test(void)
848 URL_COMPONENTS urlComp;
853 /* test NULL lpUrlComponents */
854 ret = InternetCreateUrlA(NULL, 0, NULL, &len);
855 SetLastError(0xdeadbeef);
856 ok(!ret, "Expected failure\n");
857 ok(GetLastError() == 0xdeadbeef,
858 "Expected 0xdeadbeef, got %ld\n", GetLastError());
859 ok(len == -1, "Expected len -1, got %ld\n", len);
861 /* test garbage lpUrlComponets */
862 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
863 SetLastError(0xdeadbeef);
864 ok(!ret, "Expected failure\n");
865 ok(GetLastError() == 0xdeadbeef,
866 "Expected 0xdeadbeef, got %ld\n", GetLastError());
867 ok(len == -1, "Expected len -1, got %ld\n", len);
869 /* test zero'ed lpUrlComponents */
870 ZeroMemory(&urlComp, sizeof(URL_COMPONENTS));
871 SetLastError(0xdeadbeef);
872 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
873 ok(!ret, "Expected failure\n");
874 ok(GetLastError() == ERROR_INVALID_PARAMETER,
875 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
876 ok(len == -1, "Expected len -1, got %ld\n", len);
878 /* test valid lpUrlComponets, NULL lpdwUrlLength */
879 fill_url_components(&urlComp);
880 SetLastError(0xdeadbeef);
881 ret = InternetCreateUrlA(&urlComp, 0, NULL, NULL);
882 ok(!ret, "Expected failure\n");
883 ok(GetLastError() == ERROR_INVALID_PARAMETER,
884 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
885 ok(len == -1, "Expected len -1, got %ld\n", len);
887 /* test valid lpUrlComponets, emptry szUrl
888 * lpdwUrlLength is size of buffer required on exit, including
889 * the terminating null when GLE == ERROR_INSUFFICIENT_BUFFER
891 SetLastError(0xdeadbeef);
892 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
893 ok(!ret, "Expected failure\n");
894 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
895 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
896 ok(len == 51, "Expected len 51, got %ld\n", len);
898 /* test correct size, NULL szUrl */
899 fill_url_components(&urlComp);
900 SetLastError(0xdeadbeef);
901 ret = InternetCreateUrlA(&urlComp, 0, NULL, &len);
902 ok(!ret, "Expected failure\n");
903 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
904 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
905 ok(len == 51, "Expected len 51, got %ld\n", len);
907 /* test valid lpUrlComponets, alloced szUrl, small size */
908 SetLastError(0xdeadbeef);
909 szUrl = HeapAlloc(GetProcessHeap(), 0, len);
911 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
912 ok(!ret, "Expected failure\n");
913 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
914 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
915 ok(len == 51, "Expected len 51, got %ld\n", len);
917 /* alloced szUrl, NULL lpszScheme
918 * shows that it uses nScheme instead
920 SetLastError(0xdeadbeef);
921 urlComp.lpszScheme = NULL;
922 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
923 ok(ret, "Expected success\n");
924 ok(GetLastError() == 0xdeadbeef,
925 "Expected 0xdeadbeef, got %ld\n", GetLastError());
926 ok(len == 50, "Expected len 50, got %ld\n", len);
927 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
929 /* alloced szUrl, invalid nScheme
930 * any nScheme out of range seems ignored
932 fill_url_components(&urlComp);
933 SetLastError(0xdeadbeef);
934 urlComp.nScheme = -3;
936 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
937 ok(ret, "Expected success\n");
938 ok(GetLastError() == 0xdeadbeef,
939 "Expected 0xdeadbeef, got %ld\n", GetLastError());
940 ok(len == 50, "Expected len 50, got %ld\n", len);
942 /* test valid lpUrlComponets, alloced szUrl */
943 fill_url_components(&urlComp);
944 SetLastError(0xdeadbeef);
946 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
947 ok(ret, "Expected success\n");
948 ok(GetLastError() == 0xdeadbeef,
949 "Expected 0xdeadbeef, got %ld\n", GetLastError());
950 ok(len == 50, "Expected len 50, got %ld\n", len);
951 ok(strstr(szUrl, "80") == NULL, "Didn't expect to find 80 in szUrl\n");
952 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
954 /* valid username, NULL password */
955 fill_url_components(&urlComp);
956 SetLastError(0xdeadbeef);
957 urlComp.lpszPassword = NULL;
959 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
960 ok(ret, "Expected success\n");
961 ok(GetLastError() == 0xdeadbeef,
962 "Expected 0xdeadbeef, got %ld\n", GetLastError());
963 ok(len == 41, "Expected len 41, got %ld\n", len);
964 ok(!strcmp(szUrl, CREATE_URL2), "Expected %s, got %s\n", CREATE_URL2, szUrl);
966 /* valid username, empty password */
967 fill_url_components(&urlComp);
968 SetLastError(0xdeadbeef);
969 urlComp.lpszPassword = "";
971 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
972 ok(ret, "Expected success\n");
973 ok(GetLastError() == 0xdeadbeef,
974 "Expected 0xdeadbeef, got %ld\n", GetLastError());
975 ok(len == 50, "Expected len 50, got %ld\n", len);
976 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
978 /* valid password, NULL username
979 * if password is provided, username has to exist
981 fill_url_components(&urlComp);
982 SetLastError(0xdeadbeef);
983 urlComp.lpszUserName = NULL;
985 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
986 ok(!ret, "Expected failure\n");
987 ok(GetLastError() == ERROR_INVALID_PARAMETER,
988 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
989 ok(len == 42, "Expected len 42, got %ld\n", len);
990 ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl);
992 /* valid password, empty username
993 * if password is provided, username has to exist
995 fill_url_components(&urlComp);
996 SetLastError(0xdeadbeef);
997 urlComp.lpszUserName = "";
999 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1000 ok(ret, "Expected success\n");
1001 ok(GetLastError() == 0xdeadbeef,
1002 "Expected 0xdeadbeef, got %ld\n", GetLastError());
1003 ok(len == 50, "Expected len 50, got %ld\n", len);
1004 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1006 /* NULL username, NULL password */
1007 fill_url_components(&urlComp);
1008 SetLastError(0xdeadbeef);
1009 urlComp.lpszUserName = NULL;
1010 urlComp.lpszPassword = NULL;
1012 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1013 ok(ret, "Expected success\n");
1014 ok(GetLastError() == 0xdeadbeef,
1015 "Expected 0xdeadbeef, got %ld\n", GetLastError());
1016 ok(len == 32, "Expected len 32, got %ld\n", len);
1017 ok(!strcmp(szUrl, CREATE_URL4), "Expected %s, got %s\n", CREATE_URL4, szUrl);
1019 /* empty username, empty password */
1020 fill_url_components(&urlComp);
1021 SetLastError(0xdeadbeef);
1022 urlComp.lpszUserName = "";
1023 urlComp.lpszPassword = "";
1025 ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len);
1026 ok(ret, "Expected success\n");
1027 ok(GetLastError() == 0xdeadbeef,
1028 "Expected 0xdeadbeef, got %ld\n", GetLastError());
1029 ok(len == 50, "Expected len 50, got %ld\n", len);
1030 ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl);
1032 /* shows that nScheme is ignored, as the appearance of the port number
1033 * depends on lpszScheme and the string copied depends on lpszScheme.
1035 fill_url_components(&urlComp);
1036 HeapFree(GetProcessHeap(), 0, szUrl);
1037 urlComp.lpszScheme = "nhttp";
1038 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1039 len = strlen(CREATE_URL6) + 1;
1040 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, len);
1041 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1042 ok(ret, "Expected success\n");
1043 ok(len == strlen(CREATE_URL6), "Expected len %d, got %ld\n", strlen(CREATE_URL6) + 1, len);
1044 ok(!strcmp(szUrl, CREATE_URL6), "Expected %s, got %s\n", CREATE_URL6, szUrl);
1046 /* if lpszScheme != "http" or nPort != 80, display nPort */
1047 HeapFree(GetProcessHeap(), 0, szUrl);
1048 urlComp.lpszScheme = "http";
1049 urlComp.dwSchemeLength = strlen(urlComp.lpszScheme);
1051 szUrl = HeapAlloc(GetProcessHeap(), 0, ++len);
1052 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1053 ok(ret, "Expected success\n");
1054 ok(len == 53, "Expected len 53, got %ld\n", len);
1055 ok(strstr(szUrl, "42") != NULL, "Expected to find 42 in szUrl\n");
1056 ok(!strcmp(szUrl, CREATE_URL7), "Expected %s, got %s\n", CREATE_URL7, szUrl);
1058 HeapFree(GetProcessHeap(), 0, szUrl);
1060 memset(&urlComp, 0, sizeof(urlComp));
1061 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1062 urlComp.lpszScheme = "http";
1063 urlComp.dwSchemeLength = 0;
1064 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1065 urlComp.lpszHostName = "www.winehq.org";
1066 urlComp.dwHostNameLength = 0;
1068 urlComp.lpszUserName = "username";
1069 urlComp.dwUserNameLength = 0;
1070 urlComp.lpszPassword = "password";
1071 urlComp.dwPasswordLength = 0;
1072 urlComp.lpszUrlPath = "/site/about";
1073 urlComp.dwUrlPathLength = 0;
1074 urlComp.lpszExtraInfo = "";
1075 urlComp.dwExtraInfoLength = 0;
1076 len = strlen(CREATE_URL1);
1077 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1078 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1079 ok(ret, "Expected success\n");
1080 ok(len == strlen(CREATE_URL1), "Expected len %d, got %ld\n", strlen(CREATE_URL1), len);
1081 ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl);
1083 memset(&urlComp, 0, sizeof(urlComp));
1084 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1085 urlComp.lpszScheme = "https";
1086 urlComp.dwSchemeLength = 0;
1087 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1088 urlComp.lpszHostName = "www.winehq.org";
1089 urlComp.dwHostNameLength = 0;
1090 urlComp.nPort = 443;
1091 urlComp.lpszUserName = "username";
1092 urlComp.dwUserNameLength = 0;
1093 urlComp.lpszPassword = "password";
1094 urlComp.dwPasswordLength = 0;
1095 urlComp.lpszUrlPath = "/site/about";
1096 urlComp.dwUrlPathLength = 0;
1097 urlComp.lpszExtraInfo = "";
1098 urlComp.dwExtraInfoLength = 0;
1099 len = strlen(CREATE_URL8);
1100 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1101 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1102 ok(ret, "Expected success\n");
1103 ok(len == strlen(CREATE_URL8), "Expected len %d, got %ld\n", strlen(CREATE_URL8), len);
1104 ok(!strcmp(szUrl, CREATE_URL8), "Expected %s, got %s\n", CREATE_URL8, szUrl);
1106 HeapFree(GetProcessHeap(), 0, szUrl);
1108 memset(&urlComp, 0, sizeof(urlComp));
1109 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1110 urlComp.lpszScheme = "about";
1111 urlComp.dwSchemeLength = 5;
1112 urlComp.lpszUrlPath = "blank";
1113 urlComp.dwUrlPathLength = 5;
1114 len = strlen(CREATE_URL9);
1115 len++; /* work around bug in native wininet */
1116 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1117 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1118 ok(ret, "Expected success\n");
1119 ok(len == strlen(CREATE_URL9), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len);
1120 ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
1122 HeapFree(GetProcessHeap(), 0, szUrl);
1124 memset(&urlComp, 0, sizeof(urlComp));
1125 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1126 urlComp.lpszScheme = "about";
1127 urlComp.lpszHostName = "host";
1128 urlComp.lpszUrlPath = "blank";
1129 len = strlen(CREATE_URL10);
1130 len++; /* work around bug in native wininet */
1131 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1132 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1133 ok(ret, "Expected success\n");
1134 ok(len == strlen(CREATE_URL10), "Expected len %d, got %ld\n", strlen(CREATE_URL10), len);
1135 ok(!strcmp(szUrl, CREATE_URL10), "Expected %s, got %s\n", CREATE_URL10, szUrl);
1137 HeapFree(GetProcessHeap(), 0, szUrl);
1139 memset(&urlComp, 0, sizeof(urlComp));
1140 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1141 urlComp.nPort = 8080;
1142 urlComp.lpszScheme = "about";
1143 len = strlen(CREATE_URL11);
1144 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1145 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1146 ok(ret, "Expected success\n");
1147 ok(len == strlen(CREATE_URL11), "Expected len %d, got %ld\n", strlen(CREATE_URL11), len);
1148 ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
1150 HeapFree(GetProcessHeap(), 0, szUrl);
1152 memset(&urlComp, 0, sizeof(urlComp));
1153 urlComp.dwStructSize = sizeof(URL_COMPONENTS);
1154 urlComp.lpszScheme = "http";
1155 urlComp.dwSchemeLength = 0;
1156 urlComp.nScheme = INTERNET_SCHEME_HTTP;
1157 urlComp.lpszHostName = "www.winehq.org";
1158 urlComp.dwHostNameLength = 0;
1159 urlComp.nPort = 65535;
1160 len = strlen(CREATE_URL12);
1161 szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
1162 ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
1163 ok(ret, "Expected success\n");
1164 ok(len == strlen(CREATE_URL12), "Expected len %d, got %ld\n", strlen(CREATE_URL12), len);
1165 ok(!strcmp(szUrl, CREATE_URL12), "Expected %s, got %s\n", CREATE_URL12, szUrl);
1167 HeapFree(GetProcessHeap(), 0, szUrl);
1170 static void HttpSendRequestEx_test(void)
1176 INTERNET_BUFFERS BufferIn;
1177 DWORD dwBytesWritten;
1183 static const char szPostData[] = "mode=Test";
1184 static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
1186 hSession = InternetOpen("Wine Regression Test",
1187 INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
1188 ok( hSession != NULL ,"Unable to open Internet session\n");
1189 hConnect = InternetConnect(hSession, "crossover.codeweavers.com",
1190 INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
1192 ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
1193 hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php",
1194 NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
1195 ok( hRequest != NULL, "Failed to open request handle\n");
1198 BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS);
1199 BufferIn.Next = (LPINTERNET_BUFFERS)0xdeadcab;
1200 BufferIn.lpcszHeader = szContentType;
1201 BufferIn.dwHeadersLength = sizeof(szContentType);
1202 BufferIn.dwHeadersTotal = sizeof(szContentType);
1203 BufferIn.lpvBuffer = (LPVOID)szPostData;
1204 BufferIn.dwBufferLength = 3;
1205 BufferIn.dwBufferTotal = sizeof(szPostData)-1;
1206 BufferIn.dwOffsetLow = 0;
1207 BufferIn.dwOffsetHigh = 0;
1209 ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
1210 ok(ret, "HttpSendRequestEx Failed with error %ld\n", GetLastError());
1212 for (i = 3; szPostData[i]; i++)
1213 ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
1214 "InternetWriteFile failed\n");
1216 ok(HttpEndRequest(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
1218 ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
1219 "Unable to read response\n");
1220 szBuffer[dwBytesRead] = 0;
1222 ok(dwBytesRead == 13,"Read %lu bytes instead of 13\n",dwBytesRead);
1223 ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0,"Got string %s\n",szBuffer);
1225 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
1226 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
1227 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
1230 static void HttpHeaders_test(void)
1239 hSession = InternetOpen("Wine Regression Test",
1240 INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
1241 ok( hSession != NULL ,"Unable to open Internet session\n");
1242 hConnect = InternetConnect(hSession, "crossover.codeweavers.com",
1243 INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
1245 ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
1246 hRequest = HttpOpenRequest(hConnect, "POST", "/posttest.php",
1247 NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
1248 ok( hRequest != NULL, "Failed to open request handle\n");
1251 len = sizeof(buffer);
1252 strcpy(buffer,"Warning");
1253 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1254 buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
1256 ok(HttpAddRequestHeaders(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
1257 "Failed to add new header\n");
1260 len = sizeof(buffer);
1261 strcpy(buffer,"Warning");
1262 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1263 buffer,&len,&index),"Unable to query header\n");
1264 ok(index == 1, "Index was not incremented\n");
1265 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1266 len = sizeof(buffer);
1267 strcpy(buffer,"Warning");
1268 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1269 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
1271 ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
1272 "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
1275 len = sizeof(buffer);
1276 strcpy(buffer,"Warning");
1277 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1278 buffer,&len,&index),"Unable to query header\n");
1279 ok(index == 1, "Index was not incremented\n");
1280 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1281 len = sizeof(buffer);
1282 strcpy(buffer,"Warning");
1283 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1284 buffer,&len,&index),"Failed to get second header\n");
1285 ok(index == 2, "Index was not incremented\n");
1286 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1287 len = sizeof(buffer);
1288 strcpy(buffer,"Warning");
1289 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1290 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1292 ok(HttpAddRequestHeaders(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
1295 len = sizeof(buffer);
1296 strcpy(buffer,"Warning");
1297 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1298 buffer,&len,&index),"Unable to query header\n");
1299 ok(index == 1, "Index was not incremented\n");
1300 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1301 len = sizeof(buffer);
1302 strcpy(buffer,"Warning");
1303 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1304 buffer,&len,&index),"Failed to get second header\n");
1305 ok(index == 2, "Index was not incremented\n");
1306 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1307 len = sizeof(buffer);
1308 strcpy(buffer,"Warning");
1309 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1310 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1312 ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
1315 len = sizeof(buffer);
1316 strcpy(buffer,"Warning");
1317 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1318 buffer,&len,&index),"Unable to query header\n");
1319 ok(index == 1, "Index was not incremented\n");
1320 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1321 len = sizeof(buffer);
1322 strcpy(buffer,"Warning");
1323 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1324 buffer,&len,&index),"Failed to get second header\n");
1325 ok(index == 2, "Index was not incremented\n");
1326 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1327 len = sizeof(buffer);
1328 strcpy(buffer,"Warning");
1329 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1330 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1332 ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1335 len = sizeof(buffer);
1336 strcpy(buffer,"Warning");
1337 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
1338 buffer,&len,&index),"Unable to query header\n");
1339 ok(index == 1, "Index was not incremented\n");
1340 ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
1341 len = sizeof(buffer);
1342 strcpy(buffer,"Warning");
1343 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1344 ok(index == 2, "Index was not incremented\n");
1345 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1346 len = sizeof(buffer);
1347 strcpy(buffer,"Warning");
1348 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1350 ok(HttpAddRequestHeaders(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1353 len = sizeof(buffer);
1354 strcpy(buffer,"Warning");
1355 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
1356 ok(index == 1, "Index was not incremented\n");
1357 ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
1358 len = sizeof(buffer);
1359 strcpy(buffer,"Warning");
1360 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1361 ok(index == 2, "Index was not incremented\n");
1362 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1363 len = sizeof(buffer);
1364 strcpy(buffer,"Warning");
1365 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1367 ok(HttpAddRequestHeaders(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1370 len = sizeof(buffer);
1371 strcpy(buffer,"Warning");
1372 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
1373 ok(index == 1, "Index was not incremented\n");
1374 ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
1375 len = sizeof(buffer);
1376 strcpy(buffer,"Warning");
1377 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1378 ok(index == 2, "Index was not incremented\n");
1379 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1380 len = sizeof(buffer);
1381 strcpy(buffer,"Warning");
1382 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1384 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");
1387 len = sizeof(buffer);
1388 strcpy(buffer,"Warning");
1389 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
1390 ok(index == 1, "Index was not incremented\n");
1391 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1392 len = sizeof(buffer);
1393 strcpy(buffer,"Warning");
1394 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1395 ok(index == 2, "Index was not incremented\n");
1396 ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
1397 len = sizeof(buffer);
1398 strcpy(buffer,"Warning");
1399 ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1402 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
1403 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
1404 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
1411 InternetReadFile_test(INTERNET_FLAG_ASYNC);
1412 InternetReadFile_test(0);
1413 InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
1414 InternetCrackUrl_test();
1415 InternetOpenUrlA_test();
1416 InternetCrackUrlW_test();
1417 InternetTimeFromSystemTimeA_test();
1418 InternetTimeFromSystemTimeW_test();
1419 InternetTimeToSystemTimeA_test();
1420 InternetTimeToSystemTimeW_test();
1421 InternetCreateUrlA_test();
1422 HttpSendRequestEx_test();