37#define _SECURITY_FLAG_CERT_REV_FAILED 0x00800000
38#define _SECURITY_FLAG_CERT_INVALID_CA 0x01000000
39#define _SECURITY_FLAG_CERT_INVALID_CN 0x02000000
40#define _SECURITY_FLAG_CERT_INVALID_DATE 0x04000000
42#define TEST_URL "http://test.winehq.org/tests/hello.html"
49#define SET_EXPECT2(status, num) \
52#define SET_EXPECT(status) \
53 SET_EXPECT2(status, 1)
55#define SET_OPTIONAL2(status, num) \
56 optional[status] = num
58#define SET_OPTIONAL(status) \
59 SET_OPTIONAL2(status, 1)
63#define SET_WINE_ALLOW2(status, num) \
64 wine_allow[status] = num
66#define SET_WINE_ALLOW(status) \
67 SET_WINE_ALLOW2(status, 1)
69#define CHECK_EXPECT(status) \
71 if (!expect[status] && !optional[status] && wine_allow[status]) \
73 todo_wine ok(expect[status], "unexpected status %d (%s)\n", status, \
74 status < MAX_INTERNET_STATUS && status_string[status] ? \
75 status_string[status] : "unknown"); \
76 wine_allow[status]--; \
80 ok(expect[status] || optional[status], "unexpected status %d (%s)\n", status, \
81 status < MAX_INTERNET_STATUS && status_string[status] ? \
82 status_string[status] : "unknown"); \
83 if (expect[status]) expect[status]--; \
84 else if(optional[status]) optional[status]--; \
91#define CLEAR_NOTIFIED(status) \
92 expect[status] = optional[status] = wine_allow[status] = notified[status] = 0;
94#define CHECK_NOTIFIED2(status, num) \
96 ok(notified[status] + optional[status] == (num), \
97 "expected status %d (%s) %d times, received %d times\n", \
98 status, status < MAX_INTERNET_STATUS && status_string[status] ? \
99 status_string[status] : "unknown", (num), notified[status]); \
100 CLEAR_NOTIFIED(status); \
103#define CHECK_NOTIFIED(status) \
104 CHECK_NOTIFIED2(status, 1)
106#define CHECK_NOT_NOTIFIED(status) \
107 CHECK_NOTIFIED2(status, 0)
109#define MAX_INTERNET_STATUS (INTERNET_STATUS_COOKIE_HISTORY+1)
118#define TESTF_REDIRECT 0x01
119#define TESTF_COMPRESSED 0x02
120#define TESTF_CHUNKED 0x04
135 "http://test.winehq.org/tests/data.php",
136 "http://test.winehq.org/tests/data.php",
143 "http://test.winehq.org/tests/redirect",
144 "http://test.winehq.org/tests/hello.html",
151 "http://test.winehq.org/tests/gzip.php",
152 "http://test.winehq.org/tests/gzip.php",
155 "Accept-Encoding: gzip, deflate",
159 "http://test.winehq.org/tests/post.php",
160 "http://test.winehq.org/tests/post.php",
163 "Content-Type: application/x-www-form-urlencoded",
186 if (pGetThreadUILanguage)
188 if (pGetUserDefaultUILanguage)
247#define test_status_code(a,b) _test_status_code(__LINE__,a,b, FALSE)
248#define test_status_code_todo(a,b) _test_status_code(__LINE__,a,b, TRUE)
252 char exbuf[12], bufa[10];
259 ok_(__FILE__,
line)(
res,
"[1] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number) failed: %u\n",
GetLastError());
261 ok_(__FILE__,
line)(
code == excode,
"code = %d, expected %d\n",
code, excode);
268 ok_(__FILE__,
line)(
res,
"[2] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number index) failed: %u\n",
GetLastError());
278 ok_(__FILE__,
line)(!
strcmp(bufa, exbuf),
"unexpected status code %s, expected %s\n", bufa, exbuf);
284 "[4] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\n",
GetLastError());
291 ok_(__FILE__,
line)(!
strcmp_wa(bufw, exbuf),
"unexpected status code %s, expected %s\n", bufa, exbuf);
297 "[6] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\n",
GetLastError());
304 ok(
size ==
sizeof(bufw),
"unexpected size %d\n",
size);
321#define test_request_flags(a,b) _test_request_flags(__LINE__,a,b,FALSE)
322#define test_request_flags_todo(a,b) _test_request_flags(__LINE__,a,b,TRUE)
331 ok_(__FILE__,
line)(
res,
"InternetQueryOptionW(INTERNET_OPTION_REQUEST_FLAGS) failed: %u\n",
GetLastError());
334 flags &= ~INTERNET_REQFLAG_CACHE_WRITE_DISABLED;
336 ok_(__FILE__,
line)(
flags == exflags,
"flags = %x, expected %x\n",
flags, exflags);
339#define test_request_url(a,b) _test_request_url(__LINE__,a,b)
349 ok_(__FILE__,
line)(!
strcmp(
buf, expected_url),
"unexpected URL %s, expected %s\n",
buf, expected_url);
352#define test_http_version(a) _test_http_version(__LINE__,a)
361 ok_(__FILE__,
line)(
res,
"InternetQueryOptionW(INTERNET_OPTION_HTTP_VERSION) failed: %u\n",
GetLastError());
362 ok_(__FILE__,
line)(
v.dwMajorVersion == 1,
"dwMajorVersion = %d\n",
v.dwMajorVersion);
363 ok_(__FILE__,
line)(
v.dwMinorVersion == 1,
"dwMinorVersion = %d\n",
v.dwMinorVersion);
371 DWORD dwInternetStatus,
372 LPVOID lpvStatusInformation,
373 DWORD dwStatusInformationLength
378 switch (dwInternetStatus)
382 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %d\n",
384 (
LPCSTR)lpvStatusInformation,dwStatusInformationLength);
385 *(
LPSTR)lpvStatusInformation =
'\0';
389 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %d\n",
391 (
LPCSTR)lpvStatusInformation,dwStatusInformationLength);
392 *(
LPSTR)lpvStatusInformation =
'\0';
396 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n",
398 (
LPCSTR)lpvStatusInformation,dwStatusInformationLength);
399 ok(dwStatusInformationLength ==
strlen(lpvStatusInformation)+1,
"unexpected size %u\n",
400 dwStatusInformationLength);
401 *(
LPSTR)lpvStatusInformation =
'\0';
405 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n",
407 (
LPCSTR)lpvStatusInformation,dwStatusInformationLength);
408 ok(dwStatusInformationLength ==
strlen(lpvStatusInformation)+1,
"unexpected size %u\n",
409 dwStatusInformationLength);
410 *(
LPSTR)lpvStatusInformation =
'\0';
414 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %d\n",
416 lpvStatusInformation,dwStatusInformationLength);
419 ok(dwStatusInformationLength ==
sizeof(
DWORD),
420 "info length should be sizeof(DWORD) instead of %d\n",
421 dwStatusInformationLength);
423 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%x %d\n",
425 *(
DWORD *)lpvStatusInformation,dwStatusInformationLength);
429 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n",
431 lpvStatusInformation,dwStatusInformationLength);
434 ok(dwStatusInformationLength ==
sizeof(
DWORD),
435 "info length should be sizeof(DWORD) instead of %d\n",
436 dwStatusInformationLength);
438 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n",
440 *(
DWORD *)lpvStatusInformation,dwStatusInformationLength);
444 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n",
446 lpvStatusInformation,dwStatusInformationLength);
450 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %d\n",
452 lpvStatusInformation,dwStatusInformationLength);
456 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %d\n",
458 lpvStatusInformation,dwStatusInformationLength);
462 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %d\n",
464 lpvStatusInformation,dwStatusInformationLength);
468 "info length should be sizeof(HINTERNET) instead of %d\n",
469 dwStatusInformationLength);
471 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %d\n",
473 *(
HINTERNET *)lpvStatusInformation,dwStatusInformationLength);
479 "info length should be sizeof(HINTERNET) instead of %d\n",
480 dwStatusInformationLength);
482 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %d\n",
484 *(
HINTERNET *)lpvStatusInformation, dwStatusInformationLength);
492 "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %d\n",
493 dwStatusInformationLength);
496 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\n",
506 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %d\n",
508 (
LPCSTR)lpvStatusInformation, dwStatusInformationLength);
509 *(
LPSTR)lpvStatusInformation =
'\0';
515 trace(
"%04x:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %d\n",
517 lpvStatusInformation, dwStatusInformationLength);
521 trace(
"%04x:Callback %p 0x%lx %d %p %d\n",
523 lpvStatusInformation, dwStatusInformationLength);
533#define open_simple_request(a,b,c,d,e) _open_simple_request(__LINE__,a,b,c,d,e)
535 int port,
const char *verb,
const char *
url)
547#define close_request(a) _close_request(__LINE__,a)
560#define receive_simple_request(a,b,c) _receive_simple_request(__LINE__,a,b,c)
594 DWORD contents_length, accepts_ranges;
597 trace(
"Starting InternetReadFile test with flags 0x%x on url %s\n",
flags,
test->url);
600 trace(
"InternetOpenA <--\n");
603 ok((hi != 0x0),
"InternetOpen failed with error %u\n",
GetLastError());
604 trace(
"InternetOpenA -->\n");
606 if (hi == 0x0)
goto abort;
608 pInternetSetStatusCallbackA(hi,&
callback);
612 trace(
"InternetConnectA <--\n");
615 ok((hic != 0x0),
"InternetConnect failed with error %u\n",
GetLastError());
616 trace(
"InternetConnectA -->\n");
618 if (hic == 0x0)
goto abort;
623 trace(
"HttpOpenRequestA <--\n");
635 ok((hor != 0x0),
"HttpOpenRequest failed with error %u\n",
GetLastError());
637 trace(
"HttpOpenRequestA -->\n");
639 if (hor == 0x0)
goto abort;
646 ok(
res,
"HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n",
GetLastError());
648 ok(!
strcmp(
buffer,
""),
"HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n",
buffer);
688 trace(
"HttpSendRequestA -->\n");
689 if(
test->post_data) {
698 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
701 "Synchronous HttpSendRequest returning 0, error %u\n",
GetLastError());
702 trace(
"HttpSendRequestA <--\n");
746 ok(
res,
"InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %d\n",
GetLastError());
752 ok(
res,
"HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n",
GetLastError());
756 ok(
buffer[
length-2],
"Expected any header character, got 0x00\n");
763 ok(!
res,
"Expected 0x00, got %d\n",
res);
765 ok(length2 ==
length+1,
"Expected %d, got %d\n",
length+1, length2);
770 ok(
res,
"HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n",
GetLastError());
771 ok(
buffer[length2] == 0x00,
"Expected 0x00, got %02X\n",
buffer[length2]);
772 ok(
buffer[length2+1] == 0x77,
"Expected 0x77, got %02X\n",
buffer[length2+1]);
773 ok(length2 ==
length,
"Value should not have changed: %d != %d\n", length2,
length);
776 memset(wbuffer, 0x77,
sizeof(wbuffer));
778 ok(
res,
"HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n",
GetLastError());
779 ok(
length %
sizeof(
WCHAR) == 0,
"Expected that length is a multiple of sizeof(WCHAR), got %d.\n",
length);
782 ok(wbuffer[
length-2],
"Expected any header character, got 0x0000\n");
783 ok(!wbuffer[
length-1],
"Expected 0x0000, got %04X\n", wbuffer[
length-1]);
784 ok(!wbuffer[
length],
"Expected 0x0000, got %04X\n", wbuffer[
length]);
786 "Expected 0x7777, got %04X\n", wbuffer[
length+1]);
790 ok(!
res,
"Expected 0x00, got %d\n",
res);
792 ok(length2 %
sizeof(
WCHAR) == 0,
"Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
793 length2 /=
sizeof(
WCHAR);
794 ok(length2 ==
length+1,
"Expected %d, got %d\n",
length+1, length2);
797 memset(wbuffer, 0x77,
sizeof(wbuffer));
799 ok(
res,
"HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n",
GetLastError());
800 ok(length2 %
sizeof(
WCHAR) == 0,
"Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
801 length2 /=
sizeof(
WCHAR);
802 ok(!wbuffer[length2],
"Expected 0x0000, got %04X\n", wbuffer[length2]);
803 ok(wbuffer[length2+1] == 0x7777,
"Expected 0x7777, got %04X\n", wbuffer[length2+1]);
804 ok(length2 ==
length,
"Value should not have changed: %d != %d\n", length2,
length);
814 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n",
GetLastError());
815 ok(
index == 0,
"Index was incremented\n");
824 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n",
res,
GetLastError());
831 ok(!
res ||
index == 1,
"Index was not incremented although result is %x (index = %u)\n",
res,
index);
847 trace(
"Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",
res,
buffer);
856 "Got unexpected length %#x, GetLastError() %u, contents_length %u, accepts_ranges %#x.\n",
871 ok(!
res,
"InternetReadFile should have failed\n");
873 "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %u\n",
878 trace(
"Entering Query loop\n");
910 ok(!
length,
"InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n",
length);
913 ok(exlen,
"length = 0\n");
946 ok(!on_async,
"Returned zero size in response to request complete\n");
970 trace(
"Starting InternetReadFile chunked test\n");
972 trace(
"InternetOpenA <--\n");
974 ok((hi != 0x0),
"InternetOpen failed with error %u\n",
GetLastError());
975 trace(
"InternetOpenA -->\n");
977 if (hi == 0x0)
goto abort;
979 trace(
"InternetConnectA <--\n");
982 ok((hic != 0x0),
"InternetConnect failed with error %u\n",
GetLastError());
983 trace(
"InternetConnectA -->\n");
985 if (hic == 0x0)
goto abort;
987 trace(
"HttpOpenRequestA <--\n");
999 ok((hor != 0x0),
"HttpOpenRequest failed with error %u\n",
GetLastError());
1001 trace(
"HttpOpenRequestA -->\n");
1003 if (hor == 0x0)
goto abort;
1005 trace(
"HttpSendRequestA -->\n");
1009 "Synchronous HttpSendRequest returning 0, error %u\n",
GetLastError());
1010 trace(
"HttpSendRequestA <--\n");
1025 "Failed to get TRANSFER_ENCODING option, error %u\n",
GetLastError() );
1027 "Wrong transfer encoding '%s'\n",
buffer );
1032 ok( !
res,
"Found CONTENT_LENGTH option '%s'\n",
buffer );
1036 trace(
"Entering Query loop\n");
1041 ok(!(!
res &&
length != 0),
"InternetQueryDataAvailable failed with non-zero length\n");
1054 trace(
"ReadFile -> %i %i\n",
res,got);
1055 ok(
length == got,
"only got %u of %u available\n", got,
length );
1056 ok(
buffer[got-1] ==
'\n',
"received partial line '%s'\n",
buffer );
1069 ok( !got,
"got %u\n", got );
1074 trace(
"aborting\n");
1077 ok (
res,
"InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
1081 ok (
res,
"InternetCloseHandle of handle opened by InternetOpenA failed\n");
1093 trace(
"Starting InternetReadFileExA test with flags 0x%x\n",
flags);
1096 trace(
"InternetOpenA <--\n");
1098 ok((hi != 0x0),
"InternetOpen failed with error %u\n",
GetLastError());
1099 trace(
"InternetOpenA -->\n");
1101 if (hi == 0x0)
goto abort;
1103 pInternetSetStatusCallbackA(hi,&
callback);
1107 trace(
"InternetConnectA <--\n");
1110 ok((hic != 0x0),
"InternetConnect failed with error %u\n",
GetLastError());
1111 trace(
"InternetConnectA -->\n");
1113 if (hic == 0x0)
goto abort;
1118 trace(
"HttpOpenRequestA <--\n");
1130 ok((hor != 0x0),
"HttpOpenRequest failed with error %u\n",
GetLastError());
1132 trace(
"HttpOpenRequestA -->\n");
1134 if (hor == 0x0)
goto abort;
1161 trace(
"HttpSendRequestA -->\n");
1166 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
1169 "Synchronous HttpSendRequest returning 0, error %u\n",
GetLastError());
1170 trace(
"HttpSendRequestA <--\n");
1206 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
1220 "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
1235 ok(rc,
"InternetReadFileEx failed with error %u\n",
GetLastError());
1240 "InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %u\n",
1244 trace(
"Entering Query loop\n");
1262 trace(
"InternetReadFileEx -> PENDING\n");
1264 "Should not get ERROR_IO_PENDING without INTERNET_FLAG_ASYNC\n");
1279 trace(
"InternetReadFileEx -> SUCCEEDED\n");
1298 "InternetReadFileEx sets offsets to 0x%x%08x\n",
1308 ok(
length > 0,
"failed to read any of the document\n");
1325 "DeleteUrlCacheEntry returned %x, GetLastError() = %d\n",
ret,
GetLastError());
1328 ok((myhinternet != 0),
"InternetOpen failed, error %u\n",
GetLastError());
1338 ok((myhttp != 0),
"InternetOpenUrl failed, error %u\n",
GetLastError());
1341 totalbytes += readbytes;
1343 totalbytes += readbytes;
1344 trace(
"read 0x%08x bytes\n",totalbytes);
1365 static char szPostData[] =
"mode=Test";
1366 static const char szContentType[] =
"Content-Type: application/x-www-form-urlencoded";
1370 ok( hSession !=
NULL ,
"Unable to open Internet session\n");
1374 ok( hConnect !=
NULL,
"Unable to connect to http://test.winehq.org\n");
1379 skip(
"Network unreachable, skipping test\n" );
1400 ok(
ret,
"HttpSendRequestEx Failed with error %u\n",
error);
1405 for (
i = 3; szPostData[
i];
i++)
1407 "InternetWriteFile failed\n");
1416 "Unable to read response\n");
1417 szBuffer[dwBytesRead] = 0;
1419 ok(dwBytesRead == 13,
"Read %u bytes instead of 13\n",dwBytesRead);
1431 static const char *
types[] = {
"*",
"",
NULL };
1432 static const WCHAR slash[] = {
'/', 0}, any[] = {
'*', 0},
empty[] = {0};
1441 ok(
connect ==
NULL,
"InternetConnectA should have failed\n");
1446 ok(
connect ==
NULL,
"InternetConnectA should have failed\n");
1456 skip(
"Network unreachable, skipping test\n" );
1489 static const char cache_only_url[] =
"http://test.winehq.org/tests/cache-only";
1490 BYTE cache_headers[] =
"HTTP/1.1 200 OK\r\n\r\n";
1492 trace(
"Testing cache read...\n");
1499 li.
u.HighPart =
now.dwHighDateTime;
1500 li.
u.LowPart =
now.dwLowDateTime;
1518 cache_headers,
sizeof(cache_headers)-1,
"", 0);
1586 static const char cached_content[] =
"data read from cache";
1587 static const char *
types[] = {
"*",
"",
NULL };
1599 skip(
"Network unreachable, skipping test\n" );
1610 ok(
ret,
"InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n",
GetLastError());
1611 ok(!
strcmp(
url,
"http://test.winehq.org/tests/hello.html"),
"Wrong URL %s\n",
url);
1615 ok(!
ret,
"InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1624 ok(
ret,
"InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n",
GetLastError());
1659 ok(
ret,
"HttpSendRequest failed\n");
1683 ok(!
ret,
"InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1703 ok(
file_name[0] == 0,
"Didn't expect a file name\n");
1725 ok(!
ret,
"InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1738 ok(
ret,
"InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n",
GetLastError());
1746 ok(
lock == lock2,
"lock != lock2\n");
1780 ok( hSession !=
NULL ,
"Unable to open Internet session\n");
1784 ok( hConnect !=
NULL,
"Unable to connect to http://test.winehq.org\n");
1789 skip(
"Network unreachable, skipping test\n" );
1792 ok( hRequest !=
NULL,
"Failed to open request handle\n");
1798 buffer,&
len,&
index)==0,
"Warning hearder reported as Existing\n");
1801 "Failed to add new header\n");
1808 ok(
index == 1,
"Index was not incremented\n");
1810 ok(
len == 5,
"Invalid length (exp. 5, got %d)\n",
len);
1823 ok(
index == 0,
"Index was incremented\n");
1825 ok(
len == 6,
"Invalid length (exp. 6, got %d)\n",
len);
1834 ok(
len > 40,
"Invalid length (exp. more than 40, got %d)\n",
len);
1835 ok(
index == 0,
"Index was incremented\n");
1844 ok(
len > 40,
"Invalid length (exp. more than 40, got %d)\n",
len);
1845 ok(
index == 0,
"Index was incremented\n");
1853 ok(
len > 40,
"Invalid length (exp. more than 40, got %d)\n",
len);
1854 ok(
index == 0,
"Index was incremented\n");
1864 ok(
len +
sizeof(
CHAR) <= oldlen,
"Result longer than advertised\n");
1868 ok(
strncmp(
buffer,
"POST /tests/post.php HTTP/1", 25)==0,
"Invalid beginning of headers string\n");
1870 ok(
index == 0,
"Index was incremented\n");
1880 ok(
len > 80,
"Invalid length (exp. more than 80, got %d)\n",
len);
1881 ok(
index == 0,
"Index was incremented\n");
1886 len =
sizeof(wbuffer);
1887 memset(wbuffer,
'x',
sizeof(wbuffer));
1889 wbuffer,&
len,&
index),
"Unable to query header\n");
1890 ok(
len +
sizeof(
WCHAR) <= oldlen,
"Result longer than advertised\n");
1892 ok((
len <
sizeof(wbuffer)-
sizeof(
WCHAR)) && (wbuffer[
len/
sizeof(
WCHAR)] == 0),
"No NUL at end\n");
1893 ok(
index == 0,
"Index was incremented\n");
1903 ok(
len == 2 ||
len == 4 ,
"Expected 2 or 4, got %d\n",
len);
1905 ok(
index == 0,
"Index was incremented\n");
1908 "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
1915 ok(
index == 1,
"Index was not incremented\n");
1921 ok(
index == 2,
"Index was not incremented\n");
1935 ok(
index == 1,
"Index was not incremented\n");
1941 ok(
index == 2,
"Index was not incremented\n");
1955 ok(
index == 1,
"Index was not incremented\n");
1961 ok(
index == 2,
"Index was not incremented\n");
1975 ok(
index == 1,
"Index was not incremented\n");
1980 ok(
index == 2,
"Index was not incremented\n");
1992 ok(
index == 1,
"Index was not incremented\n");
1997 ok(
index == 2,
"Index was not incremented\n");
2009 ok(
index == 1,
"Index was not incremented\n");
2010 ok(
strcmp(
buffer,
"test2, test4, test5; test6")==0,
"incorrect string was returned(%s)\n",
buffer);
2014 ok(
index == 2,
"Index was not incremented\n");
2026 ok(
index == 1,
"Index was not incremented\n");
2031 ok(
index == 2,
"Index was not incremented\n");
2044 ok(
index == 1,
"Index was not incremented\n");
2049 "Failed to add header with malformed entries in list\n");
2055 ok(
index == 1,
"Index was not incremented\n");
2061 ok(
index == 1,
"Index was not incremented\n");
2067 ok(
index == 1,
"Index was not incremented\n");
2078 ok(
index == 1,
"index was not incremented\n");
2088 "header still present\n");
2098"Garbage: Header\r\n";
2101"HTTP/1.1 100 Continue\r\n";
2104"HTTP/1.1 100 Continue\r\n"
2105"Server: winecontinue\r\n"
2106"Tag: something witty\r\n";
2109"HTTP/1.1 200 OK\r\n"
2110"Server: winetest\r\n"
2114"HTTP/1.1 201 OK\r\n"
2115"Server: winetest\r\n"
2119"HTTP/1.1 200 OK\r\n"
2120"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2121"Server: winetest\r\n"
2122"Content-Length: 0\r\n"
2123"Set-Cookie: one\r\n"
2124"Set-Cookie: two\r\n"
2129"HTTP/1.1 200 OK\r\n"
2130"Content-Length: %I64u\r\n"
2134"HTTP/1.1 200 OK\r\n"
2135"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2136"Server: winetest\r\n"
2137"Content-Length: 0\r\n"
2138"Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
2142"HTTP/1.1 200 OK\r\n"
2143"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
2144"Server: winetest\r\n"
2145"Content-Length: 0\r\n"
2146"Set-Cookie: testcookie=testvalue\r\n"
2150"HTTP/1.1 400 Bad Request\r\n"
2151"Server: winetest\r\n"
2155"HTTP/1.1 401 Unauthorized\r\n"
2156"Server: winetest\r\n"
2157"Connection: close\r\n"
2158"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
2162"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed\r\n"
2163"HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"
2165"Server: winetest\r\n";
2168"HTTP/1.1 407 Proxy Authentication Required\r\n"
2169"Server: winetest\r\n"
2170"Proxy-Connection: close\r\n"
2171"Proxy-Authenticate: Basic realm=\"placebo\"\r\n"
2176"<HEAD><TITLE>wininet test page</TITLE></HEAD>\r\n"
2177"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
2181"HTTP/1.1 200 OK\r\n"
2182"Connection: Keep-Alive\r\n"
2183"Content-Length: 18\r\n\r\n"
2184"HTTP/1.1 211 OK\r\n\r\n";
2187"HTTP/1.1 210 OK\r\n"
2188"Connection: Keep-Alive\r\n"
2189"Content-Length: 19\r\n\r\n"
2190"HTTP/1.1 211 OK\r\n\r\n";
2210 int last_request = 0;
2211 char host_header[22];
2212 char host_header_override[30];
2237 sprintf(host_header,
"Host: localhost:%d", si->
port);
2238 sprintf(host_header_override,
"Host: test.local:%d\r\n", si->
port);
2279 if (
strstr(
buffer,
"Proxy-Authorization: Basic bWlrZToxMTAx"))
2289 if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2422 static const char nocontentmsg[] =
"HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n";
2427 static const char conn_close_response[] =
"HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nsome content";
2428 send(
c, conn_close_response,
sizeof(conn_close_response)-1, 0);
2430 trace(
"closing connection\n");
2432 if (
strstr(
buffer,
"GET /test_cache_control_no_cache"))
2434 static const char no_cache_response[] =
"HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\n\r\nsome content";
2436 send(
c, no_cache_response,
sizeof(no_cache_response)-1, 0);
2440 if (
strstr(
buffer,
"GET /test_cache_control_no_store"))
2442 static const char no_cache_response[] =
"HTTP/1.1 200 OK\r\nCache-Control: junk, \t No-StOrE\r\n\r\nsome content";
2443 send(
c, no_cache_response,
sizeof(no_cache_response)-1, 0);
2447 static const char gzip_response[] =
"HTTP/1.1 200 OK\r\nContent-Encoding: gzip\r\nContent-Type: text/html\r\n\r\n"
2448 "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x4b\xaf\xca\x2c\x50\x28"
2449 "\x49\x2d\x2e\xe1\x02\x00\x62\x92\xc7\x6c\x0a\x00\x00\x00";
2451 send(
c, gzip_response,
sizeof(gzip_response), 0);
2456 static const char head_response[] =
2457 "HTTP/1.1 200 OK\r\n"
2458 "Connection: Keep-Alive\r\n"
2459 "Content-Length: 100\r\n"
2462 send(
c, head_response,
sizeof(head_response), 0);
2476 static char msg[] =
"HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
2477 static int seen_content_length;
2479 if (!seen_content_length)
2483 seen_content_length = 1;
2497 trace(
"closing connection\n");
2500 if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2507 if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2514 if (
strstr(
buffer,
"Authorization: Basic dXNlcjE6cHdkMQ=="))
2521 if (
strstr(
buffer,
"Authorization: Bearer dXNlcjE6cHdkMQ=="))
2523 else if (
strstr(
buffer,
"Authorization: Basic dXNlcjpwd2Q="))
2558 if (
strstr(
buffer,
"/test_cookie_check_host_override"))
2565 if (
strstr(
buffer,
"/test_cookie_check_different_host"))
2582 const char *page1_mid =
page1 + (
sizeof page1 - 1)/2;
2583 const char *page1_end =
page1 +
sizeof page1 - 1;
2587 send(
c, page1_mid, page1_end - page1_mid, 0);
2613 if (
strstr(
buffer,
"Authorization: Basic dGVzdDE6cGFzcw=="))
2620 if (
strstr(
buffer,
"Authorization: Basic dGVzdDE6cGFzczI="))
2628 }
while (!last_request);
2642 trace(
"basic request %s %s\n", verb,
url);
2679 skip(
"missing proxy header, not testing remaining proxy headers\n");
2682 ok(!
strcmp(
buffer,
"Basic realm=\"placebo\""),
"proxy auth info wrong\n");
2689 ok(
r,
"HttpQueryInfo failed\n");
2690 ok(!
strcmp(
buffer,
"Proxy Authentication Required"),
"proxy text wrong\n");
2694 ok(
r,
"HttpQueryInfo failed\n");
2699 ok(
r,
"HttpQueryInfo failed\n");
2705 ok(
r ==
FALSE,
"HttpQueryInfo failed\n");
2716 WCHAR bufferW[0x40];
2717 static const char url_fmt[] =
"http://test.winehq.org:%u/test2";
2720 useragent[] =
"winetest";
2721 static const WCHAR usernameW[] = {
'm',
'i',
'k',
'e',0},
2722 passwordW[] = {
'1',
'1',
'0',
'1',0},
2723 useragentW[] = {
'w',
'i',
'n',
'e',
't',
'e',
's',
't',0};
2731 ok(hi ==
NULL ||
broken(!!hi) ,
"open should have failed\n");
2735 ok(hi !=
NULL,
"open failed\n");
2739 ok(hc !=
NULL,
"connect failed\n");
2742 ok(
hr !=
NULL,
"HttpOpenRequest failed\n");
2748 ok(!
r,
"unexpected success\n");
2749 ok(sz == 1,
"got %u\n", sz);
2755 ok(!
r,
"unexpected success\n");
2756 ok(sz == 1,
"got %u\n", sz);
2762 ok(!sz,
"got %u\n", sz);
2768 ok(!sz,
"got %u\n", sz);
2774 ok(!
r,
"unexpected success\n");
2775 ok(sz == 1,
"got %u\n", sz);
2781 ok(!
r,
"unexpected success\n");
2782 ok(sz == 1,
"got %u\n", sz);
2788 ok(!sz,
"got %u\n", sz);
2794 ok(!sz,
"got %u\n", sz);
2800 ok(!
r,
"unexpected success\n");
2801 ok(sz == 34,
"got %u\n", sz);
2807 ok(sz == 33,
"got %u\n", sz);
2813 win_skip(
"skipping proxy tests on broken wininet\n");
2821 ok(!
r,
"unexpected success\n");
2824 ok(
r,
"failed to set user\n");
2827 ok(
r,
"failed to set user\n");
2842 ok(!
r,
"unexpected success\n");
2850 ok(!
r,
"unexpected success\n");
2856 ok(
r,
"failed to get username\n");
2861 sz =
sizeof(bufferW);
2863 ok(
r,
"failed to get username\n");
2864 ok(!
lstrcmpW(bufferW, usernameW),
"wrong username\n");
2865 ok(sz ==
lstrlenW(usernameW),
"got %u\n", sz);
2868 ok(
r,
"failed to set user\n");
2873 ok(
r,
"failed to get username\n");
2878 ok(
r,
"failed to set useragent\n");
2885 ok(!
r,
"unexpected success\n");
2886 ok(sz ==
strlen(useragent) + 1,
"got %u\n", sz);
2891 ok(
r,
"failed to get user agent\n");
2893 ok(sz ==
strlen(useragent),
"got %u\n", sz);
2900 ok(!
r,
"unexpected success\n");
2904 sz =
sizeof(bufferW);
2906 ok(
r,
"failed to get user agent\n");
2907 ok(!
lstrcmpW(bufferW, useragentW),
"wrong user agent\n");
2908 ok(sz ==
lstrlenW(useragentW),
"got %u\n", sz);
2911 ok(
r,
"failed to set user\n");
2918 ok(!
r,
"unexpected success\n");
2924 ok(
r,
"failed to get user\n");
2933 ok(!
r,
"unexpected success\n");
2937 sz =
sizeof(bufferW);
2939 ok(
r,
"failed to get user\n");
2940 ok(!
lstrcmpW(bufferW, usernameW),
"wrong user\n");
2941 ok(sz ==
lstrlenW(usernameW),
"got %u\n", sz);
2944 ok(
r,
"failed to set password\n");
2951 ok(!
r,
"unexpected success\n");
2957 ok(
r,
"failed to get password\n");
2966 ok(!
r,
"unexpected success\n");
2970 sz =
sizeof(bufferW);
2972 ok(
r,
"failed to get password\n");
2973 ok(!
lstrcmpW(bufferW, passwordW),
"wrong password\n");
2974 ok(sz ==
lstrlenW(passwordW),
"got %u\n", sz);
2983 ok(!
r,
"unexpected success\n");
2989 ok(
r,
"failed to get url\n");
2998 ok(!
r,
"unexpected success\n");
3002 sz =
sizeof(bufferW);
3004 ok(
r,
"failed to get url\n");
3010 ok(
r,
"failed to set password\n");
3017 ok(!
r,
"unexpected success\n");
3023 ok(
r,
"failed to get password\n");
3032 ok(!
r,
"unexpected success\n");
3036 sz =
sizeof(bufferW);
3038 ok(
r,
"failed to get password\n");
3039 ok(!
lstrcmpW(bufferW, passwordW),
"wrong password\n");
3040 ok(sz ==
lstrlenW(passwordW),
"got %u\n", sz);
3045 win_skip(
"skipping proxy tests on broken wininet\n");
3051 ok(
r,
"HttpQueryInfo failed\n");
3060 ok(hi !=
NULL,
"InternetOpen failed\n");
3063 ok(hc !=
NULL,
"InternetConnect failed\n");
3066 ok(
hr !=
NULL,
"HttpOpenRequest failed\n");
3081 static const char authorization[] =
"Authorization: Basic dXNlcjpwd2Q=";
3082 static const char connection[] =
"Connection: Close";
3083 static const char *
types[2] = {
"*",
NULL };