Author: akhaldi
Date: Wed Jul 22 19:43:32 2015
New Revision: 68560
URL:
http://svn.reactos.org/svn/reactos?rev=68560&view=rev
Log:
[WININET_WINETEST] Sync with Wine Staging 1.7.47. CORE-9924
Modified:
trunk/rostests/winetests/wininet/http.c
trunk/rostests/winetests/wininet/urlcache.c
Modified: trunk/rostests/winetests/wininet/http.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?…
==============================================================================
--- trunk/rostests/winetests/wininet/http.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/wininet/http.c [iso-8859-1] Wed Jul 22 19:43:32 2015
@@ -1437,7 +1437,9 @@
BYTE buf[100];
HANDLE file;
BOOL ret;
-
+ FILETIME filetime_zero = {0};
+
+ static const char cached_content[] = "data read from cache";
static const char *types[] = { "*", "", NULL };
session = InternetOpenA("Wine Regression Test",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
@@ -1497,9 +1499,13 @@
ok(InternetCloseHandle(request), "Close request handle failed\n");
- file = CreateFileA(file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ file = CreateFileA(file_name, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n",
GetLastError());
+ ret = WriteFile(file, cached_content, sizeof(cached_content), &size, NULL);
+ ok(ret && size, "WriteFile failed: %d, %d\n", ret, size);
+ ret = CommitUrlCacheEntryA(url, file_name, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY, NULL, 0, NULL, 0);
+ ok(ret, "CommitUrlCacheEntry failed: %d\n", GetLastError());
CloseHandle(file);
/* Send the same request, requiring it to be retrieved from the cache */
@@ -1512,7 +1518,17 @@
ret = InternetReadFile(request, buf, sizeof(buf), &size);
ok(ret, "InternetReadFile failed: %u\n", GetLastError());
ok(size == 100, "size = %u\n", size);
-
+ buf[99] = 0;
+ todo_wine ok(!strcmp((char*)buf, cached_content), "incorrect page data:
%s\n", (char*)buf);
+
+ ok(InternetCloseHandle(request), "Close request handle failed\n");
+
+ DeleteUrlCacheEntryA(url);
+ request = HttpOpenRequestA(connect, "GET", "/tests/hello.html",
NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ todo_wine ok(!ret, "HttpSendRequest succeeded\n");
+ if(!ret)
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n",
GetLastError());
ok(InternetCloseHandle(request), "Close request handle failed\n");
request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, types,
INTERNET_FLAG_NO_CACHE_WRITE, 0);
@@ -1979,6 +1995,22 @@
"Set-Cookie: two\r\n"
"\r\n";
+static const char okmsg_cookie_path[] =
+"HTTP/1.1 200 OK\r\n"
+"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
+"Server: winetest\r\n"
+"Content-Length: 0\r\n"
+"Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
+"\r\n";
+
+static const char okmsg_cookie[] =
+"HTTP/1.1 200 OK\r\n"
+"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
+"Server: winetest\r\n"
+"Content-Length: 0\r\n"
+"Set-Cookie: testcookie=testvalue\r\n"
+"\r\n";
+
static const char notokmsg[] =
"HTTP/1.1 400 Bad Request\r\n"
"Server: winetest\r\n"
@@ -2040,6 +2072,7 @@
WSADATA wsaData;
int last_request = 0;
char host_header[22];
+ char host_header_override[30];
static BOOL test_b = FALSE;
static int test_no_cache = 0;
@@ -2066,6 +2099,7 @@
SetEvent(si->hEvent);
sprintf(host_header, "Host: localhost:%d", si->port);
+ sprintf(host_header_override, "Host: test.local:%d\r\n", si->port);
do
{
@@ -2188,7 +2222,7 @@
}
if (strstr(buffer, "/testC"))
{
- if (strstr(buffer, "Cookie: cookie=biscuit"))
+ if (strstr(buffer, "cookie=biscuit"))
send(c, okmsg, sizeof okmsg-1, 0);
else
send(c, notokmsg, sizeof notokmsg-1, 0);
@@ -2326,6 +2360,86 @@
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "HEAD /upload.txt"))
+ {
+ if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
+ if (strstr(buffer, "PUT /upload2.txt"))
+ {
+ if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_path1"))
+ {
+ if (strstr(buffer, "subcookie=data"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_path2"))
+ {
+ if (strstr(buffer, "subcookie2=data"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_set_path"))
+ {
+ send(c, okmsg_cookie_path, sizeof okmsg_cookie_path-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_merge"))
+ {
+ if (strstr(buffer, "subcookie=data") &&
+ !strstr(buffer, "manual_cookie=test"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_set_host_override"))
+ {
+ send(c, okmsg_cookie, sizeof okmsg_cookie-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_check_host_override"))
+ {
+ if (strstr(buffer, "Cookie:") && strstr(buffer,
"testcookie=testvalue"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_check_different_host"))
+ {
+ if (!strstr(buffer, "foo") &&
+ strstr(buffer, "cookie=biscuit"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_host_override"))
+ {
+ if (strstr(buffer, host_header_override))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "HEAD /test_auth_host1"))
+ {
+ if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzcw=="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
+ if (strstr(buffer, "HEAD /test_auth_host2"))
+ {
+ if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzczI="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
c = -1;
@@ -2913,6 +3027,251 @@
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+}
+
+static void test_header_override(int port)
+{
+ char buffer[128], host_header_override[30], full_url[128];
+ HINTERNET ses, con, req;
+ DWORD size, count, err;
+ BOOL ret;
+
+ sprintf(host_header_override, "Host: test.local:%d\r\n", port);
+ sprintf(full_url, "http://localhost:%d/test_host_override", port);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpen failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnect failed\n");
+
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ size = sizeof(buffer) - 1;
+ count = 0;
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(req, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,
&size, &count);
+ err = GetLastError();
+ ok(!ret, "HttpQueryInfo succeeded\n");
+ ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error
ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
+
+ size = sizeof(buffer) - 1;
+ memset(buffer, 0, sizeof(buffer));
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size);
+ ok(ret, "InternetQueryOption failed\n");
+ ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer);
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u,
HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ size = sizeof(buffer) - 1;
+ count = 0;
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(req, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,
&size, &count);
+ ok(ret, "HttpQueryInfo failed\n");
+
+ size = sizeof(buffer) - 1;
+ memset(buffer, 0, sizeof(buffer));
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size);
+ ok(ret, "InternetQueryOption failed\n");
+ ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer);
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u,
HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u,
HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 400);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u,
HTTP_ADDREQ_FLAG_REPLACE);
+ err = GetLastError();
+ ok(!ret, "HttpAddRequestHeaders succeeded\n");
+ ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error
ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 400);
+
+ InternetCloseHandle(req);
+ InternetSetCookieA("http://localhost", "cookie",
"biscuit");
+ req = HttpOpenRequestA(con, NULL, "/testC", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_set_host_override", NULL,
NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", NULL,
NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", NULL,
NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetSetCookieA("http://test.local", "foo", "bar");
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host",
NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host",
NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, "test1",
"pass", INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA( con, "HEAD", "/test_auth_host1", NULL,
NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA( ses, "localhost", port, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host1", NULL,
NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, "test1",
"pass2", INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL,
NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL,
NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
test_status_code(req, 200);
@@ -3540,7 +3899,7 @@
HINTERNET ses, con, req;
DWORD size, error;
BOOL ret;
- char buffer[64];
+ char buffer[256];
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
@@ -3568,7 +3927,7 @@
size = sizeof(buffer);
ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
- ok(!strcmp(buffer, "cookie=not biscuit"), "got '%s' expected
\'cookie=not biscuit\'\n", buffer);
+ ok(!!strstr(buffer, "cookie=not biscuit"), "got '%s' expected
\'cookie=not biscuit\'\n", buffer);
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
@@ -3579,9 +3938,61 @@
size = sizeof(buffer);
ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
- ok(!strcmp(buffer, "cookie=biscuit"), "got '%s' expected
\'cookie=biscuit\'\n", buffer);
+ ok(!strstr(buffer, "cookie=not biscuit"), "'%s' should not
contain \'cookie=not biscuit\'\n", buffer);
+ ok(!!strstr(buffer, "cookie=biscuit"), "'%s' should contain
\'cookie=biscuit\'\n", buffer);
InternetCloseHandle(req);
+
+ InternetSetCookieA("http://localhost/testCCCC", "subcookie",
"data");
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1/abc", NULL, NULL,
NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_set_path", NULL, NULL,
NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path2", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 400);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_merge", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, "Cookie: manual_cookie=test\r\n", ~0u,
HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed: %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
InternetCloseHandle(con);
InternetCloseHandle(ses);
}
@@ -4162,8 +4573,10 @@
con = InternetConnectA(ses, "localhost", port, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
+ /* On XP there is a weird bug that the following tests fail if certain cookies
+ * are set. We workaround this problem by passing INTERNET_FLAG_NO_COOKIES as flag.
*/
req = HttpOpenRequestA(con, "POST",
"/test_request_content_length", NULL, NULL, NULL,
- INTERNET_FLAG_KEEP_CONNECTION, 0);
+ INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_COOKIES, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
@@ -4219,6 +4632,59 @@
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
+}
+
+static void test_basic_auth_credentials_reuse(int port)
+{
+ HINTERNET ses, con, req;
+ DWORD status, size;
+ BOOL ret;
+
+ ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 );
+ ok( ses != NULL, "InternetOpenA failed\n" );
+
+ con = InternetConnectA( ses, "localhost", port, "user",
"pwd",
+ INTERNET_SERVICE_HTTP, 0, 0 );
+ ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
+
+ req = HttpOpenRequestA( con, "HEAD", "/upload.txt", NULL, NULL,
NULL, 0, 0 );
+ ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
+
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
+
+ status = 0xdeadbeef;
+ size = sizeof(status);
+ ret = HttpQueryInfoA( req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
&status, &size, NULL );
+ ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
+ ok( status == 200, "got %u\n", status );
+
+ InternetCloseHandle( req );
+ InternetCloseHandle( con );
+ InternetCloseHandle( ses );
+
+ ses = InternetOpenA( "winetest", 0, NULL, NULL, 0 );
+ ok( ses != NULL, "InternetOpenA failed\n" );
+
+ con = InternetConnectA( ses, "localhost", port, NULL, NULL,
+ INTERNET_SERVICE_HTTP, 0, 0 );
+ ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
+
+ req = HttpOpenRequestA( con, "PUT", "/upload2.txt", NULL, NULL,
NULL, 0, 0 );
+ ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
+
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
+
+ status = 0xdeadbeef;
+ size = sizeof(status);
+ ret = HttpQueryInfoA( req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
&status, &size, NULL );
+ ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
+ ok( status == 200, "got %u\n", status );
+
+ InternetCloseHandle( req );
+ InternetCloseHandle( con );
+ InternetCloseHandle( ses );
}
static void test_http_connection(void)
@@ -4248,6 +4714,7 @@
test_basic_request(si.port, "GET", "/test6");
test_basic_request(si.port, "GET", "/testF");
test_connection_header(si.port);
+ test_header_override(si.port);
test_http1_1(si.port);
test_cookie_header(si.port);
test_basic_authentication(si.port);
@@ -4268,6 +4735,7 @@
test_head_request(si.port);
test_request_content_length(si.port);
test_accept_encoding(si.port);
+ test_basic_auth_credentials_reuse(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
@@ -4763,7 +5231,13 @@
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed: %d\n", GetLastError());
+ ok(ret || broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT),
+ "HttpSendRequest failed: %d\n", GetLastError());
+ if (!ret)
+ {
+ win_skip("Cannot connect to https.\n");
+ goto done;
+ }
size = sizeof(flags);
ret = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_FLAGS, &flags,
&size);
@@ -4888,6 +5362,7 @@
}
HeapFree(GetProcessHeap(), 0, certificate_structW);
+done:
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
Modified: trunk/rostests/winetests/wininet/urlcache.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/urlcach…
==============================================================================
--- trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] Wed Jul 22 19:43:32 2015
@@ -222,16 +222,16 @@
* is NULL.
*/
ret = IsUrlCacheEntryExpiredA(NULL, 0, NULL);
- ok(!ret == ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
+ ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(NULL, 0, &ft);
- ok(!ret == ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
+ ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d,
"expected time to be unchanged, got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime);
ret = IsUrlCacheEntryExpiredA(test_url, 0, NULL);
- ok(!ret == ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
+ ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
/* The return value should indicate whether the URL is expired,
* and the filetime indicates the last modified time, but a cache entry
@@ -314,7 +314,7 @@
ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(uncached_url, 0, &ft);
- ok(!ret == ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
+ ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
"expected time (0,0), got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime);
@@ -367,6 +367,7 @@
static void test_urlcacheA(void)
{
+ static char long_url[300] = "http://www.winehq.org/";
static char ok_header[] = "HTTP/1.0 200 OK\r\n\r\n";
BOOL ret;
HANDLE hFile;
@@ -376,6 +377,7 @@
DWORD cbCacheEntryInfo;
static const FILETIME filetime_zero;
FILETIME now;
+ int len;
ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
@@ -811,6 +813,30 @@
ret = pDeleteUrlCacheEntryA(test_hash_collisions2);
ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
}
+
+ len = strlen(long_url);
+ memset(long_url+len, 'a', sizeof(long_url)-len);
+ long_url[sizeof(long_url)-1] = 0;
+ ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
+ ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
+ check_file_exists(filenameA);
+ DeleteFileA(filenameA);
+
+ ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
+ ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
+ check_file_exists(filenameA);
+ DeleteFileA(filenameA);
+
+ long_url[250] = 0;
+ ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
+ ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
+ check_file_exists(filenameA);
+ DeleteFileA(filenameA);
+
+ ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
+ ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
+ check_file_exists(filenameA);
+ DeleteFileA(filenameA);
}
static void test_urlcacheW(void)