#include <wine/test.h>
+/* Undocumented security flags */
+#define _SECURITY_FLAG_CERT_REV_FAILED 0x00800000
+#define _SECURITY_FLAG_CERT_INVALID_CA 0x01000000
+#define _SECURITY_FLAG_CERT_INVALID_CN 0x02000000
+#define _SECURITY_FLAG_CERT_INVALID_DATE 0x04000000
+
#define TEST_URL "http://test.winehq.org/tests/hello.html"
static BOOL first_connection_to_test_url = TRUE;
status < MAX_INTERNET_STATUS && status_string[status] ? \
status_string[status] : "unknown"); \
if (expect[status]) expect[status]--; \
- else optional[status]--; \
+ else if(optional[status]) optional[status]--; \
} \
notified[status]++; \
}while(0)
TESTF_REDIRECT
},
{
- "http://www.codeweavers.com/",
- "http://www.codeweavers.com/",
- "www.codeweavers.com",
- "",
+ "http://test.winehq.org/tests/gzip.php",
+ "http://test.winehq.org/tests/gzip.php",
+ "test.winehq.org",
+ "/tests/gzip.php",
"Accept-Encoding: gzip, deflate",
TESTF_COMPRESSED
},
char *post_data = NULL;
BOOL res, on_async = TRUE;
CHAR buffer[4000];
- DWORD length, exlen = 0, post_len = 0;
+ WCHAR wbuffer[4000];
+ DWORD length, length2, index, exlen = 0, post_len = 0;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %d\n", GetLastError());
length = sizeof(buffer)-1;
+ memset(buffer, 0x77, sizeof(buffer));
res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length,0x0);
ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
- buffer[length]=0;
+ /* show that the function writes data past the length returned */
+ ok(buffer[length-2], "Expected any header character, got 0x00\n");
+ ok(!buffer[length-1], "Expected 0x00, got %02X\n", buffer[length-1]);
+ ok(!buffer[length], "Expected 0x00, got %02X\n", buffer[length]);
+ ok(buffer[length+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length+1]);
+
+ length2 = length;
+ res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0);
+ ok(!res, "Expected 0x00, got %d\n", res);
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
+ ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
+ /* the in length of the buffer must be +1 but the length returned does not count this */
+ length2 = length+1;
+ memset(buffer, 0x77, sizeof(buffer));
+ res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0);
+ ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
+ ok(buffer[length2] == 0x00, "Expected 0x00, got %02X\n", buffer[length2]);
+ ok(buffer[length2+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length2+1]);
+ ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
+
+ length = sizeof(wbuffer)-sizeof(WCHAR);
+ memset(wbuffer, 0x77, sizeof(wbuffer));
+ res = HttpQueryInfoW(hor, HTTP_QUERY_RAW_HEADERS, wbuffer, &length, 0x0);
+ ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
+ ok(length % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length);
+ length /= sizeof(WCHAR);
+ /* show that the function writes data past the length returned */
+ ok(wbuffer[length-2], "Expected any header character, got 0x0000\n");
+ ok(!wbuffer[length-1], "Expected 0x0000, got %04X\n", wbuffer[length-1]);
+ ok(!wbuffer[length], "Expected 0x0000, got %04X\n", wbuffer[length]);
+ ok(wbuffer[length+1] == 0x7777 || broken(wbuffer[length+1] != 0x7777),
+ "Expected 0x7777, got %04X\n", wbuffer[length+1]);
+
+ length2 = length*sizeof(WCHAR);
+ res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
+ ok(!res, "Expected 0x00, got %d\n", res);
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
+ ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
+ length2 /= sizeof(WCHAR);
+ ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
+ /* the in length of the buffer must be +1 but the length returned does not count this */
+ length2 = (length+1)*sizeof(WCHAR);
+ memset(wbuffer, 0x77, sizeof(wbuffer));
+ res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
+ ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
+ ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
+ length2 /= sizeof(WCHAR);
+ ok(!wbuffer[length2], "Expected 0x0000, got %04X\n", wbuffer[length2]);
+ ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]);
+ ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
length = sizeof(buffer);
res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length);
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer);
+ index = 0;
+ length = 0;
+ SetLastError(0xdeadbeef);
+ ok(HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,NULL,&length,&index) == FALSE,"Query worked\n");
+ if(test->flags & TESTF_COMPRESSED)
+ ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
+ "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
+ ok(index == 0, "Index was incremented\n");
+
+ index = 0;
length = 16;
- res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
+ res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,&index);
trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
if(test->flags & TESTF_COMPRESSED)
ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
+ ok(!res || index == 1, "Index was not incremented although result is %x (index = %u)\n", res, index);
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
{
if (flags & INTERNET_FLAG_ASYNC)
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ /* IE11 calls those in InternetQueryDataAvailable call. */
+ SET_OPTIONAL(INTERNET_STATUS_RECEIVING_RESPONSE);
+ SET_OPTIONAL(INTERNET_STATUS_RESPONSE_RECEIVED);
+
length = 0;
res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
+
+ CLEAR_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
+
if (flags & INTERNET_FLAG_ASYNC)
{
if (res)
exlen = length;
ok(exlen, "length = 0\n");
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+ CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
ok(req_error, "req_error = 0\n");
continue;
}else {
}else {
ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
}
+ CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
+
trace("LENGTH %d\n", length);
if(test->flags & TESTF_CHUNKED)
ok(length <= 8192, "length = %d, expected <= 8192\n", length);
hSession = InternetOpenA("Wine Regression Test",
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
ok( hSession != NULL ,"Unable to open Internet session\n");
- hConnect = InternetConnectA(hSession, "crossover.codeweavers.com",
+ hConnect = InternetConnectA(hSession, "test.winehq.org",
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
0);
- ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
- hRequest = HttpOpenRequestA(hConnect, "POST", "/posttest.php",
+ ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
+ hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
{
hSession = InternetOpenA("Wine Regression Test",
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
ok( hSession != NULL ,"Unable to open Internet session\n");
- hConnect = InternetConnectA(hSession, "crossover.codeweavers.com",
+ hConnect = InternetConnectA(hSession, "test.winehq.org",
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
0);
- ok( hConnect != NULL, "Unable to connect to http://crossover.codeweavers.com\n");
- hRequest = HttpOpenRequestA(hConnect, "POST", "/posttest.php",
+ ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
+ hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
{
strcpy(buffer,"Warning");
ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
+ ok(index == 0, "Index was incremented\n");
ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */
ok(len == 6, "Invalid length (exp. 6, got %d)\n", len); /* unlike success, the length includes the NULL-terminator */
ok((len < sizeof(buffer)-sizeof(CHAR)) && (buffer[len/sizeof(CHAR)] == 0),"No NUL at end\n");
ok(len == strlen(buffer) * sizeof(CHAR), "Length wrong\n");
/* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
- ok(strncmp(buffer, "POST /posttest.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
+ ok(strncmp(buffer, "POST /tests/post.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
ok(index == 0, "Index was incremented\n");
static DWORD CALLBACK server_thread(LPVOID param)
{
struct server_info *si = param;
- int r, c, i, on, count = 0;
+ int r, c = -1, i, on, count = 0;
SOCKET s;
struct sockaddr_in sa;
char buffer[0x100];
do
{
- c = accept(s, NULL, NULL);
+ if(c == -1)
+ c = accept(s, NULL, NULL);
memset(buffer, 0, sizeof buffer);
for(i=0; i<(sizeof buffer-1); i++)
else
send(c, notokmsg, sizeof(notokmsg)-1, 0);
}
+ if (strstr(buffer, "HEAD /test_head")) {
+ static const char head_response[] =
+ "HTTP/1.1 200 OK\r\n"
+ "Connection: Keep-Alive\r\n"
+ "Content-Length: 100\r\n"
+ "\r\n";
+
+ send(c, head_response, sizeof(head_response), 0);
+ continue;
+ }
if (strstr(buffer, "GET /send_from_buffer"))
send(c, send_buffer, strlen(send_buffer), 0);
if (strstr(buffer, "/test_cache_control_verb"))
shutdown(c, 2);
closesocket(c);
+ c = -1;
} while (!last_request);
closesocket(s);
{
static const char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
static const char connection[] = "Connection: Close";
-
static const char *types[2] = { "*", NULL };
+ char data[32];
HINTERNET session, connect, request;
- DWORD size, status;
+ DWORD size, status, data_len;
BOOL ret;
session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status);
InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+
+ connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
request = HttpOpenRequestA(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
size = sizeof(status);
ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
ok(ret, "HttpQueryInfo failed\n");
- ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status);
+ ok(status == 200, "got status %u, expected 200\n", status);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+
+ connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, "POST", "/test7b", NULL, NULL, types, 0, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ data_len = sizeof(data);
+ memset(data, 'a', sizeof(data));
+ ret = HttpSendRequestA(request, connection, ~0u, data, data_len);
+ ok(ret, "HttpSendRequest failed\n");
+
+ status = 0;
+ size = sizeof(status);
+ ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ ok(ret, "HttpQueryInfo failed\n");
+ ok(status == 200, "got status %u, expected 200\n", status);
InternetCloseHandle(request);
InternetCloseHandle(connect);
res = InternetReadFile(req, buf, avail, &size);
ok(res, "InternetReadFile failed: %u\n", GetLastError());
+ /* IE11 calls those in InternetQueryDataAvailable call. */
+ SET_OPTIONAL(INTERNET_STATUS_RECEIVING_RESPONSE);
+ SET_OPTIONAL(INTERNET_STATUS_RESPONSE_RECEIVED);
+
res = InternetQueryDataAvailable(req, &avail, 0, 0);
ok(!res && (GetLastError() == ERROR_IO_PENDING),
"Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
ok(!avail, "avail = %u, expected 0\n", avail);
+ CLEAR_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
+
SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION);
SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED);
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
SetEvent(conn_close_event);
-#ifdef ROSTESTS_73_FIXED
WaitForSingleObject(hCompleteEvent, INFINITE);
-#else /* ROSTESTS_73_FIXED */
- ok(WaitForSingleObject(hCompleteEvent, 5000) == WAIT_OBJECT_0, "Wait timed out\n");
-#endif /* ROSTESTS_73_FIXED */
ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
+ CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
InternetCloseHandle(hi);
}
+static void test_head_request(int port)
+{
+ DWORD len, content_length;
+ HINTERNET ses, con, req;
+ BYTE buf[100];
+ BOOL ret;
+
+ 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, "HEAD", "/test_head", 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: %u\n", GetLastError());
+
+ len = sizeof(content_length);
+ content_length = -1;
+ ret = HttpQueryInfoA(req, HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_CONTENT_LENGTH, &content_length, &len, 0);
+ ok(ret, "HttpQueryInfo dailed: %u\n", GetLastError());
+ ok(len == sizeof(DWORD), "len = %u\n", len);
+ ok(content_length == 100, "content_length = %u\n", content_length);
+
+ len = -1;
+ ret = InternetReadFile(req, buf, sizeof(buf), &len);
+ ok(ret, "InternetReadFile failed: %u\n", GetLastError());
+
+ len = -1;
+ ret = InternetReadFile(req, buf, sizeof(buf), &len);
+ ok(ret, "InternetReadFile failed: %u\n", GetLastError());
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+}
+
static void test_HttpQueryInfo(int port)
{
HINTERNET hi, hc, hr;
test_connection_closing(si.port);
test_cache_control_verb(si.port);
test_successive_HttpSendRequest(si.port);
+ test_head_request(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
ok(!info.lpszSignatureAlgName, "lpszSignatureAlgName = %s\n", info.lpszSignatureAlgName);
ok(!info.lpszEncryptionAlgName, "lpszEncryptionAlgName = %s\n", info.lpszEncryptionAlgName);
ok(!info.lpszProtocolName, "lpszProtocolName = %s\n", info.lpszProtocolName);
- ok(info.dwKeySize == 128, "dwKeySize = %u\n", info.dwKeySize);
+ ok(info.dwKeySize == 128 || info.dwKeySize == 256, "dwKeySize = %u\n", info.dwKeySize);
release_cert_info(&info);
}
}
}
-#define test_secflags_option(a,b) _test_secflags_option(__LINE__,a,b)
-static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags)
+#define test_secflags_option(a,b,c) _test_secflags_option(__LINE__,a,b,c)
+static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags)
{
DWORD flags, size;
BOOL res;
size = sizeof(flags);
res = InternetQueryOptionW(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size);
ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError());
- ok_(__FILE__,line)(flags == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n", flags, ex_flags);
+ ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n",
+ flags, ex_flags);
/* Option 98 is undocumented and seems to be the same as INTERNET_OPTION_SECURITY_FLAGS */
flags = 0xdeadbeef;
size = sizeof(flags);
res = InternetQueryOptionW(req, 98, &flags, &size);
ok_(__FILE__,line)(res, "InternetQueryOptionW(98) failed: %u\n", GetLastError());
- ok_(__FILE__,line)(flags == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n", flags, ex_flags);
+ ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n",
+ flags, ex_flags);
}
#define set_secflags(a,b,c) _set_secflags(__LINE__,a,b,c)
return;
}
- test_secflags_option(req, 0);
+ test_secflags_option(req, 0, 0);
test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
set_secflags(req, TRUE, SECURITY_FLAG_IGNORE_REVOCATION);
- test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION);
+ test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION, 0);
set_secflags(req, TRUE, SECURITY_FLAG_IGNORE_CERT_CN_INVALID);
- test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID);
+ test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID, 0);
set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_UNKNOWN_CA);
- test_secflags_option(req, SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID);
+ test_secflags_option(req, SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID, 0);
flags = SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_SECURE;
res = InternetSetOptionW(req, 99, &flags, sizeof(flags));
SET_EXPECT(INTERNET_STATUS_NAME_RESOLVED);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */
SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
CHECK_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME);
CHECK_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2);
+ CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
test_request_flags(req, 0);
test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA
- |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_STRENGTH_STRONG);
+ |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_STRENGTH_STRONG, 0);
res = InternetReadFile(req, buf, sizeof(buf), &size);
ok(res, "InternetReadFile failed: %u\n", GetLastError());
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */
SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION);
SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED);
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
}
HeapFree(GetProcessHeap(), 0, cert);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
- CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfoA(HTTP_QUERY_CONTENT_ENCODING) failed: %u\n", GetLastError());
test_request_flags(req, 8);
- test_secflags_option(req, 0x800000);
+ /* IE11 finds both rev failure and invalid CA. Previous versions required rev failure
+ to be ignored before invalid CA was reported. */
+ test_secflags_option(req, _SECURITY_FLAG_CERT_REV_FAILED, _SECURITY_FLAG_CERT_INVALID_CA);
set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_REVOCATION);
- test_secflags_option(req, 0x800000|SECURITY_FLAG_IGNORE_REVOCATION);
+ test_secflags_option(req, _SECURITY_FLAG_CERT_REV_FAILED|SECURITY_FLAG_IGNORE_REVOCATION, _SECURITY_FLAG_CERT_INVALID_CA);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
test_request_flags(req, INTERNET_REQFLAG_NO_HEADERS);
- test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|0x1800000);
+ test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0);
test_security_info("https://test.winehq.com/data/some_file.html?q", ERROR_INTERNET_ITEM_NOT_FOUND, 0);
set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_UNKNOWN_CA);
- test_secflags_option(req, 0x1800000|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_UNKNOWN_CA
- |SECURITY_FLAG_IGNORE_REVOCATION);
+ test_secflags_option(req, _SECURITY_FLAG_CERT_INVALID_CA|_SECURITY_FLAG_CERT_REV_FAILED
+ |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_UNKNOWN_CA, 0);
test_http_version(req);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */
SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
WaitForSingleObject(hCompleteEvent, INFINITE);
ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2);
+ CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
test_request_flags(req, 0);
test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION
- |SECURITY_FLAG_STRENGTH_STRONG|0x1800000);
+ |SECURITY_FLAG_STRENGTH_STRONG|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0);
test_cert_struct(req, &test_winehq_com_cert);
- test_security_info("https://test.winehq.com/data/some_file.html?q", 0, 0x1800000);
+ test_security_info("https://test.winehq.com/data/some_file.html?q", 0,
+ _SECURITY_FLAG_CERT_INVALID_CA|_SECURITY_FLAG_CERT_REV_FAILED);
res = InternetReadFile(req, buf, sizeof(buf), &size);
ok(res, "InternetReadFile failed: %u\n", GetLastError());
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_STRENGTH_STRONG
- |SECURITY_FLAG_IGNORE_REVOCATION|0x1800000);
+ |SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0);
test_http_version(req);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */
SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
WaitForSingleObject(hCompleteEvent, INFINITE);
ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2);
+ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2);
+ CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
test_request_flags(req, 0);
test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_STRENGTH_STRONG
- |SECURITY_FLAG_IGNORE_REVOCATION|0x1800000);
+ |SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0);
res = InternetReadFile(req, buf, sizeof(buf), &size);
ok(res, "InternetReadFile failed: %u\n", GetLastError());
ret = HttpQueryInfoA(req, HTTP_QUERY_USER_AGENT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
err = GetLastError();
ok(ret, "HttpQueryInfo failed\n");
- ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err);
InternetCloseHandle(req);
sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]),
"POST",
"test.winehq.org",
- "tests/posttest.php",
+ "tests/post.php",
"Public ID=codeweavers"
},
{
sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]),
"POST",
"test.winehq.org",
- "tests/posttest.php"
+ "tests/post.php"
},
{
async_send_request_ex_resolve_failure_test,
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]);
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]);
InternetReadFile_test(0, &test_data[1]);
- first_connection_to_test_url = TRUE;
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[2]);
test_security_flags();
InternetReadFile_test(0, &test_data[2]);
ok(retval == 0,"Got wrong return value %d\n",retval);
ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
- SetLastError(0xdeadbeef);
len=strlen(useragent)+1;
buffer=HeapAlloc(GetProcessHeap(),0,len);
retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
- err=GetLastError();
ok(retval == 1,"Got wrong return value %d\n",retval);
if (retval)
{
ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
}
- ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
HeapFree(GetProcessHeap(),0,buffer);
SetLastError(0xdeadbeef);
todo_wine ok(!ret, "InternetSetCookie succeeded\n");
}
+static void test_cookie_attrs(void)
+{
+ char buf[100];
+ DWORD size, state;
+ BOOL ret;
+
+ if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "InternetGetSecurityInfoByURLA")) {
+ win_skip("Skipping cookie attributes tests. Too old IE.\n");
+ return;
+ }
+
+ ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=data; httponly");
+ ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data; httponly", 0, 0);
+ ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION,
+ "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
+
+ size = sizeof(buf);
+ ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
+ ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
+
+ state = InternetSetCookieExA("http://cookie.attrs.com/bar",NULL,"A=data; httponly", INTERNET_COOKIE_HTTPONLY, 0);
+ ok(state == COOKIE_STATE_ACCEPT,"InternetSetCookieEx failed: %u\n", GetLastError());
+
+ size = sizeof(buf);
+ ret = InternetGetCookieA("http://cookie.attrs.com/", NULL, buf, &size);
+ ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned: %x (%u)\n", ret, GetLastError());
+
+ size = sizeof(buf);
+ ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, 0, NULL);
+ ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
+
+ size = sizeof(buf);
+ ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
+ ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
+ ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
+
+ /* Try to override httponly cookie with non-httponly one */
+ ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=test");
+ ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
+
+ SetLastError(0xdeadbeef);
+ state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data", 0, 0);
+ ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION,
+ "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
+
+ size = sizeof(buf);
+ ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
+ ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
+ ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
+
+}
+
static void test_cookie_url(void)
{
WCHAR bufw[512];
{
HINTERNET hi, hc;
static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
+ static const WCHAR szServer2[] = { 's','e','r','v','e','r','=',0 };
static const WCHAR szEmpty[] = { 0 };
static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
ok( r == TRUE, "return wrong\n");
- /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
- ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
+ /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
+ ok( sz == 14 || sz == 16 || sz == 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz);
sz = 0x20;
memset(buffer, 0, sizeof buffer);
ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
/* before XP SP2, buffer is "server; server" */
- ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
+ ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer) || !lstrcmpW(szServer2, buffer),
+ "cookie data wrong %s\n", wine_dbgstr_w(buffer));
sz = sizeof(buffer);
r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
ok(ret == FALSE, "InternetQueryOption should've failed\n");
ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
- SetLastError(0xdeadbeef);
ulArg = 11;
ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
- ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
SetLastError(0xdeadbeef);
ulArg = 4;
test_get_cookie();
test_complicated_cookie();
test_cookie_url();
+ test_cookie_attrs();
test_version();
test_null();
test_Option_PerConnectionOption();