#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)
wine_allow[MAX_INTERNET_STATUS], notified[MAX_INTERNET_STATUS];
static const char *status_string[MAX_INTERNET_STATUS];
-static HANDLE hCompleteEvent, conn_close_event;
+static HANDLE hCompleteEvent, conn_close_event, conn_wait_event, server_req_rec_event;
static DWORD req_error;
+static BOOL is_ie7plus = TRUE;
#define TESTF_REDIRECT 0x01
#define TESTF_COMPRESSED 0x02
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
},
static void _test_status_code(unsigned line, HINTERNET req, DWORD excode, BOOL is_todo)
{
DWORD code, size, index;
- char exbuf[10], bufa[10];
+ char exbuf[12], bufa[10];
WCHAR bufw[10];
BOOL res;
size = sizeof(code);
res = HttpQueryInfoA(req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &code, &size, NULL);
ok_(__FILE__,line)(res, "[1] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number) failed: %u\n", GetLastError());
- if (is_todo)
- todo_wine ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode);
- else
+ todo_wine_if (is_todo)
ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode);
ok_(__FILE__,line)(size == sizeof(code), "size = %u\n", size);
size = sizeof(code);
res = HttpQueryInfoA(req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &code, &size, &index);
ok_(__FILE__,line)(res, "[2] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number index) failed: %u\n", GetLastError());
- if (is_todo)
- todo_wine ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode);
- else
- ok_(__FILE__,line)(!index, "index = %d, expected 0\n", code);
+ ok_(__FILE__,line)(!index, "index = %d, expected 0\n", index);
ok_(__FILE__,line)(size == sizeof(code), "size = %u\n", size);
sprintf(exbuf, "%u", excode);
size = sizeof(bufa);
res = HttpQueryInfoA(req, HTTP_QUERY_STATUS_CODE, bufa, &size, NULL);
ok_(__FILE__,line)(res, "[3] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
- if (is_todo)
- todo_wine ok_(__FILE__,line)(!strcmp(bufa, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
- else
+ todo_wine_if (is_todo)
ok_(__FILE__,line)(!strcmp(bufa, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
ok_(__FILE__,line)(size == strlen(exbuf), "unexpected size %d for \"%s\"\n", size, exbuf);
size = sizeof(bufw);
res = HttpQueryInfoW(req, HTTP_QUERY_STATUS_CODE, bufw, &size, NULL);
ok_(__FILE__,line)(res, "[5] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
- if (is_todo)
- todo_wine ok_(__FILE__,line)(!strcmp_wa(bufw, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
- else
+ todo_wine_if (is_todo)
ok_(__FILE__,line)(!strcmp_wa(bufw, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
ok_(__FILE__,line)(size == strlen(exbuf)*sizeof(WCHAR), "unexpected size %d for \"%s\"\n", size, exbuf);
/* FIXME: Remove once we have INTERNET_REQFLAG_CACHE_WRITE_DISABLED implementation */
flags &= ~INTERNET_REQFLAG_CACHE_WRITE_DISABLED;
- if(!is_todo)
+ todo_wine_if (is_todo)
ok_(__FILE__,line)(flags == exflags, "flags = %x, expected %x\n", flags, exflags);
- else
- todo_wine ok_(__FILE__,line)(flags == exflags, "flags = %x, expected %x\n", flags, exflags);
}
#define test_http_version(a) _test_http_version(__LINE__,a)
}
}
+typedef struct {
+ HINTERNET session;
+ HINTERNET connection;
+ HINTERNET request;
+} test_request_t;
+
+#define open_simple_request(a,b,c,d,e) _open_simple_request(__LINE__,a,b,c,d,e)
+static void _open_simple_request(unsigned line, test_request_t *req, const char *host,
+ int port, const char *verb, const char *url)
+{
+ req->session = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok_(__FILE__,line)(req->session != NULL, "InternetOpenA failed: %u\n", GetLastError());
+
+ req->connection = InternetConnectA(req->session, host, port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok_(__FILE__,line)(req->connection != NULL, "InternetConnectA failed: %u\n", GetLastError());
+
+ req->request = HttpOpenRequestA(req->connection, verb, url, NULL, NULL, NULL, 0, 0);
+ ok_(__FILE__,line)(req->request != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
+}
+
+#define close_request(a) _close_request(__LINE__,a)
+static void _close_request(unsigned line, test_request_t *req)
+{
+ BOOL ret;
+
+ ret = InternetCloseHandle(req->request);
+ ok_(__FILE__,line)(ret, "InternetCloseHandle(request) failed: %u\n", GetLastError());
+ ret = InternetCloseHandle(req->connection);
+ ok_(__FILE__,line)(ret, "InternetCloseHandle(connection) failed: %u\n", GetLastError());
+ ret = InternetCloseHandle(req->session);
+ ok_(__FILE__,line)(ret, "InternetCloseHandle(session) failed: %u\n", GetLastError());
+}
+
+#define receive_simple_request(a,b,c) _receive_simple_request(__LINE__,a,b,c)
+static DWORD _receive_simple_request(unsigned line, HINTERNET req, char *buf, size_t buf_size)
+{
+ DWORD read = 0;
+ BOOL ret;
+
+ ret = InternetReadFile(req, buf, buf_size, &read);
+ ok_(__FILE__,line)(ret, "InternetReadFile failed: %u\n", GetLastError());
+
+ return read;
+}
+
static void close_async_handle(HINTERNET handle, HANDLE complete_event, int handle_cnt)
{
BOOL res;
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;
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
length = 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());
- ok(length == 0, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %d\n", length);
+ ok(length == 0 || (length == 1 && !*buffer) /* win10 */, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %d\n", length);
ok(!strcmp(buffer, ""), "HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n", buffer);
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
if(test->flags & TESTF_COMPRESSED) {
BOOL b = TRUE;
- res = InternetSetOption(hor, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
+ res = InternetSetOptionA(hor, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
ok(res || broken(!res && GetLastError() == ERROR_INTERNET_INVALID_OPTION),
"InternetSetOption failed: %u\n", GetLastError());
if(!res)
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);
{
BOOL res;
CHAR buffer[4000];
- DWORD length;
+ DWORD length, got;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
trace("got %u available\n",length);
if (length)
{
- DWORD got;
char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
res = InternetReadFile(hor,buffer,length,&got);
if (!got) break;
}
if (length == 0)
+ {
+ got = 0xdeadbeef;
+ res = InternetReadFile( hor, buffer, 1, &got );
+ ok( res, "InternetReadFile failed: %u\n", GetLastError() );
+ ok( !got, "got %u\n", got );
break;
+ }
}
abort:
trace("aborting\n");
DWORD length;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
- INTERNET_BUFFERS inetbuffers;
+ INTERNET_BUFFERSA inetbuffers;
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ if(is_ie7plus) {
+ rc = InternetReadFileExW(hor, NULL, 0, 0xdeadcafe);
+ ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER),
+ "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
+ rc ? "TRUE" : "FALSE", GetLastError());
+ }
+
/* tests invalid dwStructSize */
- inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS)+1;
+ inetbuffers.dwStructSize = sizeof(inetbuffers)+1;
inetbuffers.lpcszHeader = NULL;
inetbuffers.dwHeadersLength = 0;
inetbuffers.dwBufferLength = 10;
inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, 10);
inetbuffers.dwOffsetHigh = 1234;
inetbuffers.dwOffsetLow = 5678;
- rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
+ rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER),
"InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n",
rc ? "TRUE" : "FALSE", GetLastError());
test_request_flags(hor, 0);
/* tests to see whether lpcszHeader is used - it isn't */
- inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
- inetbuffers.lpcszHeader = (LPCTSTR)0xdeadbeef;
+ inetbuffers.dwStructSize = sizeof(inetbuffers);
+ inetbuffers.lpcszHeader = (LPCSTR)0xdeadbeef;
inetbuffers.dwHeadersLength = 255;
inetbuffers.dwBufferLength = 0;
inetbuffers.lpvBuffer = NULL;
inetbuffers.dwOffsetLow = 5678;
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED);
- rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe);
+ rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe);
ok(rc, "InternetReadFileEx failed with error %u\n", GetLastError());
trace("read %i bytes\n", inetbuffers.dwBufferLength);
todo_wine
CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
}
- rc = InternetReadFileEx(NULL, &inetbuffers, 0, 0xdeadcafe);
+ rc = InternetReadFileExA(NULL, &inetbuffers, 0, 0xdeadcafe);
ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE),
"InternetReadFileEx should have failed with ERROR_INVALID_HANDLE instead of %s, %u\n",
rc ? "TRUE" : "FALSE", GetLastError());
while (TRUE)
{
- inetbuffers.dwStructSize = sizeof(INTERNET_BUFFERS);
+ inetbuffers.dwStructSize = sizeof(inetbuffers);
inetbuffers.dwBufferLength = 1024;
inetbuffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, inetbuffers.dwBufferLength+1);
inetbuffers.dwOffsetHigh = 1234;
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
WaitForSingleObject(hCompleteEvent, INFINITE);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
- CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
+ CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
}
else
DWORD size, readbytes, totalbytes=0;
BOOL ret;
- ret = DeleteUrlCacheEntry(TEST_URL);
+ ret = DeleteUrlCacheEntryA(TEST_URL);
ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND,
"DeleteUrlCacheEntry returned %x, GetLastError() = %d\n", ret, GetLastError());
- myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
+ myhinternet = InternetOpenA("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
ok((myhinternet != 0), "InternetOpen failed, error %u\n",GetLastError());
size = 0x400;
- ret = InternetCanonicalizeUrl(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
+ ret = InternetCanonicalizeUrlA(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
ok( ret, "InternetCanonicalizeUrl failed, error %u\n",GetLastError());
SetLastError(0);
- myhttp = InternetOpenUrl(myhinternet, TEST_URL, 0, 0,
+ myhttp = InternetOpenUrlA(myhinternet, TEST_URL, 0, 0,
INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
if (GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
return; /* WinXP returns this when not connected to the net */
InternetCloseHandle(myhttp);
InternetCloseHandle(myhinternet);
- ret = DeleteUrlCacheEntry(TEST_URL);
+ ret = DeleteUrlCacheEntryA(TEST_URL);
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "INTERNET_FLAG_NO_CACHE_WRITE flag doesn't work\n");
}
HINTERNET hConnect;
HINTERNET hRequest;
- INTERNET_BUFFERS BufferIn;
+ INTERNET_BUFFERSA BufferIn;
DWORD dwBytesWritten, dwBytesRead, error;
CHAR szBuffer[256];
int i;
static char szPostData[] = "mode=Test";
static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
- hSession = InternetOpen("Wine Regression Test",
+ hSession = InternetOpenA("Wine Regression Test",
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
ok( hSession != NULL ,"Unable to open Internet session\n");
- hConnect = InternetConnect(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 = HttpOpenRequest(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)
{
test_request_flags(hRequest, INTERNET_REQFLAG_NO_HEADERS);
- BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS);
- BufferIn.Next = (LPINTERNET_BUFFERS)0xdeadcab;
+ BufferIn.dwStructSize = sizeof(BufferIn);
+ BufferIn.Next = (INTERNET_BUFFERSA*)0xdeadcab;
BufferIn.lpcszHeader = szContentType;
BufferIn.dwHeadersLength = sizeof(szContentType)-1;
BufferIn.dwHeadersTotal = sizeof(szContentType)-1;
BufferIn.dwOffsetHigh = 0;
SetLastError(0xdeadbeef);
- ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
+ ret = HttpSendRequestExA(hRequest, &BufferIn, NULL, 0 ,0);
error = GetLastError();
ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
test_request_flags(hRequest, INTERNET_REQFLAG_NO_HEADERS);
- ok(HttpEndRequest(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
+ ok(HttpEndRequestA(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
test_request_flags(hRequest, 0);
}
ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestW(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
ok(InternetCloseHandle(request), "Close request handle failed\n");
request = HttpOpenRequestW(connect, NULL, slash, NULL, NULL, typesW, INTERNET_FLAG_NO_CACHE_WRITE, 0);
ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
ok(InternetCloseHandle(request), "Close request handle failed\n");
trace("Testing cache read...\n");
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
for(i = 0; i < sizeof(content); i++)
content[i] = '0' + (i%10);
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);
ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
ok(!size, "size = %d\n", size);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
size = sizeof(file_name);
ret = InternetQueryOptionA(request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n", GetLastError());
- file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ file = CreateFileA(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
file_size = GetFileSize(file, NULL);
ok(file_size == 106, "file size = %u\n", file_size);
CloseHandle(file);
+ ret = DeleteFileA(file_name);
+ ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
+
ok(InternetCloseHandle(request), "Close request handle failed\n");
- file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, 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 */
- request = HttpOpenRequest(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
+ request = HttpOpenRequestA(connect, "GET", "/tests/hello.html", NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
size = sizeof(buf);
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);
ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
ok(!size, "size = %d\n", size);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
size = sizeof(file_name);
ret = InternetQueryOptionA(request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
if (ret)
{
- file = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+ file = CreateFileA(file_name, GENERIC_READ, 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());
CloseHandle(file);
test_cache_read();
}
+static void InternetLockRequestFile_test(void)
+{
+ char file_name[MAX_PATH];
+ test_request_t req;
+ HANDLE lock, lock2;
+ DWORD size;
+ BOOL ret;
+
+ open_simple_request(&req, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, "/tests/hello.html");
+
+ size = sizeof(file_name);
+ ret = InternetQueryOptionA(req.request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
+ ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
+ ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
+ ok(!size, "size = %d\n", size);
+
+ lock = NULL;
+ ret = InternetLockRequestFile(req.request, &lock);
+ ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
+
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+
+ size = sizeof(file_name);
+ ret = InternetQueryOptionA(req.request, INTERNET_OPTION_DATAFILE_NAME, file_name, &size);
+ ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n", GetLastError());
+
+ ret = InternetLockRequestFile(req.request, &lock);
+ ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
+ ok(lock != NULL, "lock == NULL\n");
+
+ ret = InternetLockRequestFile(req.request, &lock2);
+ ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
+ ok(lock == lock2, "lock != lock2\n");
+
+ ret = InternetUnlockRequestFile(lock2);
+ ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
+
+ ret = DeleteFileA(file_name);
+ ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
+
+ ok(InternetCloseHandle(req.request), "Close request handle failed\n");
+
+ ret = DeleteFileA(file_name);
+ ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
+
+ ret = InternetUnlockRequestFile(lock);
+ ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
+
+ ret = DeleteFileA(file_name);
+ ok(ret, "Deleting file returned %x(%u)\n", ret, GetLastError());
+}
+
static void HttpHeaders_test(void)
{
HINTERNET hSession;
DWORD len = 256;
DWORD oldlen;
DWORD index = 0;
+ BOOL ret;
- hSession = InternetOpen("Wine Regression Test",
+ hSession = InternetOpenA("Wine Regression Test",
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
ok( hSession != NULL ,"Unable to open Internet session\n");
- hConnect = InternetConnect(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 = HttpOpenRequest(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)
{
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
"Failed to add new header\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
ok((len < sizeof(buffer)) && (buffer[len] == 0), "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Second Index Should Not Exist\n");
index = 0;
len = 5; /* could store the string but not the NULL terminator */
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ 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 */
index = 0;
len = sizeof(buffer);
SetLastError(0xdeadbeef);
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
NULL,&len,&index) == FALSE,"Query worked\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
index = 0;
len = 15;
SetLastError(0xdeadbeef);
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
NULL,&len,&index) == FALSE,"Query worked\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
index = 0;
len = 0;
SetLastError(0xdeadbeef);
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
NULL,&len,&index) == FALSE,"Query worked\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
index = 0;
len = sizeof(buffer);
memset(buffer, 'x', sizeof(buffer));
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(len + sizeof(CHAR) <= oldlen, "Result longer than advertised\n");
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");
index = 0;
len = sizeof(buffer);
memset(buffer, 'x', sizeof(buffer));
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF,
buffer,&len,&index) == TRUE,"Query failed\n");
- ok(len == 2, "Expected 2, got %d\n", len);
- ok(strcmp(buffer, "\r\n") == 0, "Expected CRLF, got '%s'\n", buffer);
+ ok(len == 2 || len == 4 /* win10 */, "Expected 2 or 4, got %d\n", len);
+ ok(memcmp(buffer, "\r\n\r\n", len) == 0, "Expected CRLF, got '%s'\n", buffer);
ok(index == 0, "Index was incremented\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
"Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- ok(HttpAddRequestHeaders(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
+ ok(HttpAddRequestHeadersA(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
- 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");
+ ok(HttpAddRequestHeadersA(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");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
ok(index == 2, "Index was not incremented\n");
ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
len = sizeof(buffer);
strcpy(buffer,"Warning");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
/* Ensure that blank headers are ignored and don't cause a failure */
- ok(HttpAddRequestHeaders(hRequest,"\r\nBlankTest:value\r\n\r\n",-1, HTTP_ADDREQ_FLAG_ADD_IF_NEW), "Failed to add header with blank entries in list\n");
+ ok(HttpAddRequestHeadersA(hRequest,"\r\nBlankTest:value\r\n\r\n",-1, HTTP_ADDREQ_FLAG_ADD_IF_NEW), "Failed to add header with blank entries in list\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"BlankTest");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
/* Ensure that malformed header separators are ignored and don't cause a failure */
- ok(HttpAddRequestHeaders(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
+ ok(HttpAddRequestHeadersA(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
"Failed to add header with malformed entries in list\n");
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTest");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTestTwo");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
index = 0;
len = sizeof(buffer);
strcpy(buffer,"MalformedTestThree");
- ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
+ ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
- ok(HttpAddRequestHeaders(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD),
- "unable to add header %u\n", GetLastError());
+ ret = HttpAddRequestHeadersA(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "unable to add header %u\n", GetLastError());
index = 0;
buffer[0] = 0;
len = sizeof(buffer);
- ok(HttpQueryInfo(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index),
- "unable to query header %u\n", GetLastError());
+ ret = HttpQueryInfoA(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index);
+ ok(ret, "unable to query header %u\n", GetLastError());
ok(index == 1, "index was not incremented\n");
ok(!strcmp(buffer, "Basic"), "incorrect string was returned (%s)\n", buffer);
- ok(HttpAddRequestHeaders(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE),
- "unable to remove header %u\n", GetLastError());
+ ret = HttpAddRequestHeadersA(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE);
+ ok(ret, "unable to remove header %u\n", GetLastError());
index = 0;
len = sizeof(buffer);
SetLastError(0xdeadbeef);
- ok(!HttpQueryInfo(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index),
+ ok(!HttpQueryInfoA(hRequest, HTTP_QUERY_AUTHORIZATION|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, &index),
"header still present\n");
ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "got %u\n", GetLastError());
static const char expandcontmsg[] =
"HTTP/1.1 100 Continue\r\n"
"Server: winecontinue\r\n"
-"Tag: something witty\r\n"
-"\r\n";
+"Tag: something witty\r\n";
static const char okmsg[] =
"HTTP/1.1 200 OK\r\n"
"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"
static const char ok_with_length[] =
"HTTP/1.1 200 OK\r\n"
"Connection: Keep-Alive\r\n"
-"Content-Length: 23\r\n\r\n"
-"abc\r\nHTTP/1.1 211 OK\r\n\r\n";
+"Content-Length: 18\r\n\r\n"
+"HTTP/1.1 211 OK\r\n\r\n";
static const char ok_with_length2[] =
"HTTP/1.1 210 OK\r\n"
"Connection: Keep-Alive\r\n"
-"Content-Length: 24\r\n\r\n"
-"abc\r\nHTTP/1.1 211 OK\r\n\r\n";
+"Content-Length: 19\r\n\r\n"
+"HTTP/1.1 211 OK\r\n\r\n";
struct server_info {
HANDLE hEvent;
static int test_cache_gzip;
static const char *send_buffer;
+static int server_socket;
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];
+ char *buffer;
+ size_t buffer_size;
WSADATA wsaData;
int last_request = 0;
char host_header[22];
- static int test_b = 0;
+ char host_header_override[30];
static int test_no_cache = 0;
WSAStartup(MAKEWORD(1,1), &wsaData);
SetEvent(si->hEvent);
sprintf(host_header, "Host: localhost:%d", si->port);
+ sprintf(host_header_override, "Host: test.local:%d\r\n", si->port);
+ buffer = HeapAlloc(GetProcessHeap(), 0, buffer_size = 1000);
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++)
+ memset(buffer, 0, buffer_size);
+ for(i=0;; i++)
{
- r = recv(c, &buffer[i], 1, 0);
+ if(i == buffer_size)
+ buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, buffer_size *= 2);
+
+ r = recv(c, buffer+i, 1, 0);
if (r != 1)
break;
if (i<4) continue;
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "CONNECT "))
+ {
+ if (!strstr(buffer, "Content-Length: 0"))
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ else
+ send(c, proxymsg, sizeof proxymsg-1, 0);
+ }
if (strstr(buffer, "/test2"))
{
if (strstr(buffer, "Proxy-Authorization: Basic bWlrZToxMTAx"))
{
if (strstr(buffer, "Content-Length: 100"))
{
+ if (strstr(buffer, "POST /test7b"))
+ recvfrom(c, buffer, buffer_size, 0, NULL, NULL);
send(c, okmsg, sizeof okmsg-1, 0);
send(c, page1, sizeof page1-1, 0);
}
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
- if (!test_b && strstr(buffer, "/testB HTTP/1.1"))
- {
- test_b = 1;
- send(c, okmsg, sizeof okmsg-1, 0);
- recvfrom(c, buffer, sizeof buffer, 0, NULL, NULL);
- send(c, okmsg, sizeof okmsg-1, 0);
- }
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);
count = 0;
}
}
+ if (strstr(buffer, "GET /testH"))
+ {
+ send(c, ok_with_length2, sizeof(ok_with_length2)-1, 0);
+ recvfrom(c, buffer, buffer_size, 0, NULL, NULL);
+ send(c, ok_with_length, sizeof(ok_with_length)-1, 0);
+ }
if (strstr(buffer, "GET /test_no_content"))
{
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"))
if (!memcmp(buffer, "GET ", sizeof("GET ")-1) &&
!strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
else if (strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
- send(c, notokmsg, sizeof(notokmsg)-1, 0);
+ else send(c, notokmsg, sizeof(notokmsg)-1, 0);
+ }
+ if (strstr(buffer, "/test_request_content_length"))
+ {
+ static char msg[] = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
+ static int seen_content_length;
+
+ if (!seen_content_length)
+ {
+ if (strstr(buffer, "Content-Length: 0"))
+ {
+ seen_content_length = 1;
+ send(c, msg, sizeof msg-1, 0);
+ }
+ else send(c, notokmsg, sizeof notokmsg-1, 0);
+ WaitForSingleObject(hCompleteEvent, 5000);
+ }
+ else
+ {
+ if (strstr(buffer, "Content-Length: 0")) send(c, msg, sizeof msg-1, 0);
+ else send(c, notokmsg, sizeof notokmsg-1, 0);
+ WaitForSingleObject(hCompleteEvent, 5000);
+ }
}
if (strstr(buffer, "GET /test_premature_disconnect"))
trace("closing connection\n");
-
+ 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, "/async_read"))
+ {
+ const char *page1_mid = page1 + (sizeof page1 - 1)/2;
+ const char *page1_end = page1 + sizeof page1 - 1;
+ send(c, okmsg, sizeof okmsg-1, 0);
+ send(c, page1, page1_mid - page1, 0);
+ WaitForSingleObject(conn_wait_event, INFINITE);
+ send(c, page1_mid, page1_end - page1_mid, 0);
+ }
+ if (strstr(buffer, "/socket"))
+ {
+ server_socket = c;
+ SetEvent(server_req_rec_event);
+ WaitForSingleObject(conn_wait_event, INFINITE);
+ }
+ if (strstr(buffer, "/echo_request"))
+ {
+ send(c, okmsg, sizeof(okmsg)-1, 0);
+ send(c, buffer, strlen(buffer), 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;
} while (!last_request);
closesocket(s);
+ HeapFree(GetProcessHeap(), 0, buffer);
return 0;
}
static void test_basic_request(int port, const char *verb, const char *url)
{
- HINTERNET hi, hc, hr;
- DWORD r, count;
+ test_request_t req;
+ DWORD r, count, error;
char buffer[0x100];
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(hi != NULL, "open failed\n");
-
- hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(hc != NULL, "connect failed\n");
+ trace("basic request %s %s\n", verb, url);
- hr = HttpOpenRequest(hc, verb, url, NULL, NULL, NULL, 0, 0);
- ok(hr != NULL, "HttpOpenRequest failed\n");
+ open_simple_request(&req, "localhost", port, verb, url);
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
- ok(r, "HttpSendRequest failed\n");
+ SetLastError(0xdeadbeef);
+ r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ error = GetLastError();
+ ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %u\n", error);
+ ok(r, "HttpSendRequest failed: %u\n", GetLastError());
count = 0;
memset(buffer, 0, sizeof buffer);
SetLastError(0xdeadbeef);
- r = InternetReadFile(hr, buffer, sizeof buffer, &count);
+ r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
ok(r, "InternetReadFile failed %u\n", GetLastError());
ok(count == sizeof page1 - 1, "count was wrong\n");
ok(!memcmp(buffer, page1, sizeof page1), "http data wrong, got: %s\n", buffer);
- InternetCloseHandle(hr);
- InternetCloseHandle(hc);
- InternetCloseHandle(hi);
-}
-
-static void test_last_error(int port)
-{
- HINTERNET hi, hc, hr;
- DWORD error;
- BOOL r;
-
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(hi != NULL, "open failed\n");
-
- hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(hc != NULL, "connect failed\n");
-
- hr = HttpOpenRequest(hc, NULL, "/test1", NULL, NULL, NULL, 0, 0);
- ok(hr != NULL, "HttpOpenRequest failed\n");
-
- SetLastError(0xdeadbeef);
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
- error = GetLastError();
- ok(r, "HttpSendRequest failed\n");
- ok(error == ERROR_SUCCESS || broken(error != ERROR_SUCCESS), "expected ERROR_SUCCESS, got %u\n", error);
-
- InternetCloseHandle(hr);
- InternetCloseHandle(hc);
- InternetCloseHandle(hi);
+ close_request(&req);
}
static void test_proxy_indirect(int port)
{
- HINTERNET hi, hc, hr;
+ test_request_t req;
DWORD r, sz;
char buffer[0x40];
- hi = InternetOpen(NULL, 0, NULL, NULL, 0);
- ok(hi != NULL, "open failed\n");
-
- hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(hc != NULL, "connect failed\n");
-
- hr = HttpOpenRequest(hc, NULL, "/test2", NULL, NULL, NULL, 0, 0);
- ok(hr != NULL, "HttpOpenRequest failed\n");
+ open_simple_request(&req, "localhost", port, NULL, "/test2");
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
ok(r, "HttpSendRequest failed %u\n", GetLastError());
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_PROXY_AUTHENTICATE, buffer, &sz, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_PROXY_AUTHENTICATE, buffer, &sz, NULL);
ok(r || GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed: %d\n", GetLastError());
if (!r)
{
}
ok(!strcmp(buffer, "Basic realm=\"placebo\""), "proxy auth info wrong\n");
- test_status_code(hr, 407);
- test_request_flags(hr, 0);
+ test_status_code(req.request, 407);
+ test_request_flags(req.request, 0);
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &sz, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_STATUS_TEXT, buffer, &sz, NULL);
ok(r, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "Proxy Authentication Required"), "proxy text wrong\n");
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &sz, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_VERSION, buffer, &sz, NULL);
ok(r, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "HTTP/1.1"), "http version wrong\n");
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_SERVER, buffer, &sz, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_SERVER, buffer, &sz, NULL);
ok(r, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "winetest"), "http server wrong\n");
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_CONTENT_ENCODING, buffer, &sz, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_CONTENT_ENCODING, buffer, &sz, NULL);
ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo should fail\n");
ok(r == FALSE, "HttpQueryInfo failed\n");
out:
- InternetCloseHandle(hr);
- InternetCloseHandle(hc);
- InternetCloseHandle(hi);
+ close_request(&req);
}
static void test_proxy_direct(int port)
DWORD r, sz, error;
char buffer[0x40], *url;
WCHAR bufferW[0x40];
+ static const char url_fmt[] = "http://test.winehq.org:%u/test2";
static CHAR username[] = "mike",
password[] = "1101",
- useragent[] = "winetest",
- url_fmt[] = "http://test.winehq.org:%u/test2";
- static WCHAR usernameW[] = {'m','i','k','e',0},
- passwordW[] = {'1','1','0','1',0},
- useragentW[] = {'w','i','n','e','t','e','s','t',0};
+ useragent[] = "winetest";
+ static const WCHAR usernameW[] = {'m','i','k','e',0},
+ passwordW[] = {'1','1','0','1',0},
+ useragentW[] = {'w','i','n','e','t','e','s','t',0};
/* specify proxy type without the proxy and bypass */
SetLastError(0xdeadbeef);
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_PROXY, NULL, NULL, 0);
+ hi = InternetOpenW(NULL, INTERNET_OPEN_TYPE_PROXY, NULL, NULL, 0);
error = GetLastError();
ok(error == ERROR_INVALID_PARAMETER ||
broken(error == ERROR_SUCCESS) /* WinXPProSP2 */, "got %u\n", error);
ok(hi == NULL || broken(!!hi) /* WinXPProSP2 */, "open should have failed\n");
sprintf(buffer, "localhost:%d\n", port);
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0);
+ hi = InternetOpenA(NULL, INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0);
ok(hi != NULL, "open failed\n");
/* try connect without authorization */
- hc = InternetConnect(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(hc != NULL, "connect failed\n");
- hr = HttpOpenRequest(hc, NULL, "/test2", NULL, NULL, NULL, 0, 0);
+ hr = HttpOpenRequestA(hc, NULL, "/test2", NULL, NULL, NULL, 0, 0);
ok(hr != NULL, "HttpOpenRequest failed\n");
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_PASSWORD, NULL, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_PASSWORD, NULL, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == 1, "got %u\n", sz);
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, NULL, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, NULL, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == 1, "got %u\n", sz);
sz = sizeof(buffer);
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
ok(r, "unexpected failure %u\n", GetLastError());
ok(!sz, "got %u\n", sz);
sz = sizeof(buffer);
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
ok(r, "unexpected failure %u\n", GetLastError());
ok(!sz, "got %u\n", sz);
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PASSWORD, NULL, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PASSWORD, NULL, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == 1, "got %u\n", sz);
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_USERNAME, NULL, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_USERNAME, NULL, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == 1, "got %u\n", sz);
sz = sizeof(buffer);
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
ok(r, "unexpected failure %u\n", GetLastError());
ok(!sz, "got %u\n", sz);
sz = sizeof(buffer);
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
ok(r, "unexpected failure %u\n", GetLastError());
ok(!sz, "got %u\n", sz);
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_URL, NULL, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_URL, NULL, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == 34, "got %u\n", sz);
sz = sizeof(buffer);
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_URL, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_URL, buffer, &sz);
ok(r, "unexpected failure %u\n", GetLastError());
ok(sz == 33, "got %u\n", sz);
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
ok(r || broken(!r), "HttpSendRequest failed %u\n", GetLastError());
if (!r)
{
test_status_code(hr, 407);
/* set the user + password then try again */
- r = InternetSetOption(hi, INTERNET_OPTION_PROXY_USERNAME, username, 4);
+ r = InternetSetOptionA(hi, INTERNET_OPTION_PROXY_USERNAME, username, 4);
ok(!r, "unexpected success\n");
- r = InternetSetOption(hc, INTERNET_OPTION_PROXY_USERNAME, username, 4);
+ r = InternetSetOptionA(hc, INTERNET_OPTION_PROXY_USERNAME, username, 4);
ok(r, "failed to set user\n");
- r = InternetSetOption(hr, INTERNET_OPTION_PROXY_USERNAME, username, 4);
+ r = InternetSetOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, username, 4);
ok(r, "failed to set user\n");
buffer[0] = 0;
sz = 3;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
ok(!r, "unexpected failure %u\n", GetLastError());
ok(!buffer[0], "got %s\n", buffer);
ok(sz == strlen(username) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(username) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
ok(r, "failed to get username\n");
ok(!strcmp(buffer, username), "got %s\n", buffer);
ok(sz == strlen(username), "got %u\n", sz);
ok(!lstrcmpW(bufferW, usernameW), "wrong username\n");
ok(sz == lstrlenW(usernameW), "got %u\n", sz);
- r = InternetSetOption(hr, INTERNET_OPTION_PROXY_USERNAME, username, 1);
+ r = InternetSetOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, username, 1);
ok(r, "failed to set user\n");
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_USERNAME, buffer, &sz);
ok(r, "failed to get username\n");
ok(!strcmp(buffer, username), "got %s\n", buffer);
ok(sz == strlen(username), "got %u\n", sz);
- r = InternetSetOption(hi, INTERNET_OPTION_USER_AGENT, useragent, 1);
+ r = InternetSetOptionA(hi, INTERNET_OPTION_USER_AGENT, useragent, 1);
ok(r, "failed to set useragent\n");
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hi, INTERNET_OPTION_USER_AGENT, buffer, &sz);
+ r = InternetQueryOptionA(hi, INTERNET_OPTION_USER_AGENT, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(useragent) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hi, INTERNET_OPTION_USER_AGENT, buffer, &sz);
+ r = InternetQueryOptionA(hi, INTERNET_OPTION_USER_AGENT, buffer, &sz);
ok(r, "failed to get user agent\n");
ok(!strcmp(buffer, useragent), "got %s\n", buffer);
ok(sz == strlen(useragent), "got %u\n", sz);
ok(!lstrcmpW(bufferW, useragentW), "wrong user agent\n");
ok(sz == lstrlenW(useragentW), "got %u\n", sz);
- r = InternetSetOption(hr, INTERNET_OPTION_USERNAME, username, 1);
+ r = InternetSetOptionA(hr, INTERNET_OPTION_USERNAME, username, 1);
ok(r, "failed to set user\n");
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(username) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_USERNAME, buffer, &sz);
ok(r, "failed to get user\n");
ok(!strcmp(buffer, username), "got %s\n", buffer);
ok(sz == strlen(username), "got %u\n", sz);
ok(!lstrcmpW(bufferW, usernameW), "wrong user\n");
ok(sz == lstrlenW(usernameW), "got %u\n", sz);
- r = InternetSetOption(hr, INTERNET_OPTION_PASSWORD, password, 1);
+ r = InternetSetOptionA(hr, INTERNET_OPTION_PASSWORD, password, 1);
ok(r, "failed to set password\n");
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(password) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PASSWORD, buffer, &sz);
ok(r, "failed to get password\n");
ok(!strcmp(buffer, password), "got %s\n", buffer);
ok(sz == strlen(password), "got %u\n", sz);
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_URL, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_URL, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(url) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_URL, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_URL, buffer, &sz);
ok(r, "failed to get url\n");
ok(!strcmp(buffer, url), "got %s\n", buffer);
ok(sz == strlen(url), "got %u\n", sz);
ok(sz == strlen(url), "got %u\n", sz);
HeapFree(GetProcessHeap(), 0, url);
- r = InternetSetOption(hr, INTERNET_OPTION_PROXY_PASSWORD, password, 4);
+ r = InternetSetOptionA(hr, INTERNET_OPTION_PROXY_PASSWORD, password, 4);
ok(r, "failed to set password\n");
buffer[0] = 0;
sz = 0;
SetLastError(0xdeadbeef);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
ok(!r, "unexpected success\n");
ok(sz == strlen(password) + 1, "got %u\n", sz);
buffer[0] = 0;
sz = sizeof(buffer);
- r = InternetQueryOption(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
+ r = InternetQueryOptionA(hr, INTERNET_OPTION_PROXY_PASSWORD, buffer, &sz);
ok(r, "failed to get password\n");
ok(!strcmp(buffer, password), "got %s\n", buffer);
ok(sz == strlen(password), "got %u\n", sz);
ok(!lstrcmpW(bufferW, passwordW), "wrong password\n");
ok(sz == lstrlenW(passwordW), "got %u\n", sz);
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ r = HttpSendRequestW(hr, NULL, 0, NULL, 0);
if (!r)
{
win_skip("skipping proxy tests on broken wininet\n");
}
ok(r, "HttpSendRequest failed %u\n", GetLastError());
sz = sizeof buffer;
- r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE, buffer, &sz, NULL);
+ r = HttpQueryInfoA(hr, HTTP_QUERY_STATUS_CODE, buffer, &sz, NULL);
ok(r, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "200"), "proxy code wrong\n");
+ InternetCloseHandle(hr);
+ InternetCloseHandle(hc);
+ InternetCloseHandle(hi);
+
+ sprintf(buffer, "localhost:%d\n", port);
+ hi = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PROXY, buffer, NULL, 0);
+ ok(hi != NULL, "InternetOpen failed\n");
+
+ hc = InternetConnectA(hi, "test.winehq.org", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(hc != NULL, "InternetConnect failed\n");
+
+ hr = HttpOpenRequestA(hc, "POST", "/test2", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ ok(hr != NULL, "HttpOpenRequest failed\n");
+
+ r = HttpSendRequestA(hr, NULL, 0, (char *)"data", sizeof("data"));
+ ok(r, "HttpSendRequest failed %u\n", GetLastError());
+
+ test_status_code(hr, 407);
+
done:
InternetCloseHandle(hr);
InternetCloseHandle(hc);
static void test_header_handling_order(int port)
{
- static char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
- static char connection[] = "Connection: Close";
-
+ 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 = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(session != NULL, "InternetOpen failed\n");
- connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(connect != NULL, "InternetConnect failed\n");
- request = HttpOpenRequest(connect, NULL, "/test3", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ request = HttpOpenRequestA(connect, NULL, "/test3", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpAddRequestHeaders(request, authorization, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ret = HttpAddRequestHeadersA(request, authorization, ~0u, HTTP_ADDREQ_FLAG_ADD);
ok(ret, "HttpAddRequestHeaders failed\n");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
test_status_code(request, 200);
InternetCloseHandle(request);
- request = HttpOpenRequest(connect, NULL, "/test4", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ request = HttpOpenRequestA(connect, NULL, "/test4", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(request, connection, ~0u, NULL, 0);
+ ret = HttpSendRequestA(request, connection, ~0u, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
status = 0;
size = sizeof(status);
- ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ 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);
InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+
+ connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
- request = HttpOpenRequest(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ request = HttpOpenRequestA(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpAddRequestHeaders(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
ok(ret, "HttpAddRequestHeaders failed\n");
- ret = HttpSendRequest(request, connection, ~0u, NULL, 0);
+ ret = HttpSendRequestA(request, connection, ~0u, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
status = 0;
size = sizeof(status);
- ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ 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, INTERNET_FLAG_KEEP_CONNECTION, 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, NULL, 0, data, data_len);
+ ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+
+ 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);
HINTERNET ses, con, req;
BOOL ret;
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- req = HttpOpenRequest(con, NULL, "/test8", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ req = HttpOpenRequestA(con, NULL, "/test8", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
test_status_code(req, 200);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, NULL, "/test9", NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
test_status_code(req, 200);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, NULL, "/test9", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ req = HttpOpenRequestA(con, NULL, "/test9", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
test_status_code(req, 200);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, "POST", "/testA", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ req = HttpOpenRequestA(con, "POST", "/testA", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
test_status_code(req, 200);
InternetCloseHandle(ses);
}
-static void test_http1_1(int port)
+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;
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ 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 = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- req = HttpOpenRequest(con, NULL, "/testB", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
- if (ret)
- {
- InternetCloseHandle(req);
+ 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);
- req = HttpOpenRequest(con, NULL, "/testB", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
- ok(req != NULL, "HttpOpenRequest 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 = HttpSendRequest(req, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed\n");
+ 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);
+ if(ret) { /* win10 returns success */
+ trace("replacing host header is supported.\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ }else {
+ trace("replacing host header is not supported.\n");
+
+ err = GetLastError();
+ 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);
+
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
HINTERNET session, connection, req;
DWORD res;
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
- todo_wine CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
- todo_wine CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
- test_status_code_todo(req, 210);
+ test_status_code(req, 210);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
- SET_WINE_ALLOW(INTERNET_STATUS_SENDING_REQUEST);
SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED);
CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
- todo_wine CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
+ CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
- test_status_code_todo(req, 200);
+ test_status_code(req, 200);
SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION);
SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED);
CloseHandle(hCompleteEvent);
}
+static void test_successive_HttpSendRequest(int port)
+{
+ HINTERNET session, connection, req;
+ DWORD res;
+
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+
+ session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
+
+ pInternetSetStatusCallbackA(session, callback);
+
+ SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
+ connection = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
+ ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
+ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
+
+ SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
+ req = HttpOpenRequestA(connection, "GET", "/testH", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0xdeadbeaf);
+ ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
+ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
+
+ SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
+ SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
+ SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
+ SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
+ SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
+ SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
+ SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED);
+ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(!res && (GetLastError() == ERROR_IO_PENDING),
+ "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
+ WaitForSingleObject(hCompleteEvent, INFINITE);
+ ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
+
+ CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
+ CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
+ CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
+ CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ test_status_code(req, 210);
+
+ SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
+ SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
+ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
+ SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
+ SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
+ SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED);
+ SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION);
+ SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED);
+ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(!res && (GetLastError() == ERROR_IO_PENDING),
+ "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
+ WaitForSingleObject(hCompleteEvent, INFINITE);
+ ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
+
+ CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
+ CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
+ CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
+ CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
+ CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
+ CLEAR_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ test_status_code(req, 200);
+
+ SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION);
+ SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED);
+
+ close_async_handle(session, hCompleteEvent, 2);
+ CloseHandle(hCompleteEvent);
+}
static void test_no_content(int port)
{
trace("Testing 204 no content response...\n");
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- session = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
+ session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
pInternetSetStatusCallbackA(session, callback);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
- CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
- CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
close_async_handle(session, hCompleteEvent, 2);
CloseHandle(hCompleteEvent);
+
+ /*
+ * The connection should be closed before closing handle. This is true for most
+ * wininet versions (including Wine), but some old win2k versions fail to do that.
+ */
+ CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
}
static void test_conn_close(int port)
trace("Testing connection close connection...\n");
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- conn_close_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ conn_close_event = CreateEventW(NULL, FALSE, FALSE, NULL);
- session = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
+ session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
pInternetSetStatusCallbackA(session, callback);
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);
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);
trace("Testing no-cache header\n");
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
- req = HttpOpenRequest(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
sprintf(cache_url, cache_url_fmt, port, cache_control_no_cache);
- DeleteUrlCacheEntry(cache_url);
+ DeleteUrlCacheEntryA(cache_url);
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
ok(size == 12, "read %d bytes of data\n", size);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, cache_control_no_cache, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
size += read;
ok(size == 0, "read %d bytes of data\n", size);
InternetCloseHandle(req);
- DeleteUrlCacheEntry(cache_url);
+ DeleteUrlCacheEntryA(cache_url);
- req = HttpOpenRequest(con, NULL, cache_control_no_store, NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, cache_control_no_store, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
sprintf(cache_url, cache_url_fmt, port, cache_control_no_store);
- DeleteUrlCacheEntry(cache_url);
+ DeleteUrlCacheEntryA(cache_url);
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf, sizeof(buf), &read) && read)
ok(size == 12, "read %d bytes of data\n", size);
InternetCloseHandle(req);
- ret = DeleteUrlCacheEntry(cache_url);
+ ret = DeleteUrlCacheEntryA(cache_url);
ok(!ret && GetLastError()==ERROR_FILE_NOT_FOUND, "cache entry should not exist\n");
InternetCloseHandle(con);
trace("Testing reading compressed content from cache\n");
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
- req = HttpOpenRequest(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = TRUE;
- ret = InternetSetOption(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
+ ret = InternetSetOptionA(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
if(!ret && GetLastError()==ERROR_INTERNET_INVALID_OPTION) {
win_skip("INTERNET_OPTION_HTTP_DECODING not supported\n");
InternetCloseHandle(req);
}
ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
- ret = HttpSendRequest(req, "Accept-Encoding: gzip", -1, NULL, 0);
+ ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-size, &read) && read)
ok(!strncmp(raw_header, buf, size), "buf = %s\n", buf);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
+ req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = TRUE;
- ret = InternetSetOption(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
+ ret = InternetSetOptionA(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
- ret = HttpSendRequest(req, "Accept-Encoding: gzip", -1, NULL, 0);
+ ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
/* Decompression doesn't work while reading from cache */
test_cache_gzip = 0;
sprintf(cache_url, cache_url_fmt, port, get_gzip);
- DeleteUrlCacheEntry(cache_url);
+ DeleteUrlCacheEntryA(cache_url);
- req = HttpOpenRequest(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, "Accept-Encoding: gzip", -1, NULL, 0);
+ ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
ok(size == 31, "read %d bytes of data\n", size);
InternetCloseHandle(req);
- req = HttpOpenRequest(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
+ req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, INTERNET_FLAG_FROM_CACHE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = TRUE;
- ret = InternetSetOption(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
+ ret = InternetSetOptionA(req, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
- ret = HttpSendRequest(req, "Accept-Encoding: gzip", -1, NULL, 0);
+ ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
InternetCloseHandle(con);
InternetCloseHandle(ses);
- DeleteUrlCacheEntry(cache_url);
+ DeleteUrlCacheEntryA(cache_url);
}
static void test_HttpSendRequestW(int port)
DWORD error;
BOOL ret;
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(ses != NULL, "InternetOpen failed\n");
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- req = HttpOpenRequest(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
SetLastError(0xdeadbeef);
HINTERNET ses, con, req;
DWORD size, error;
BOOL ret;
- char buffer[64];
+ char buffer[256];
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- InternetSetCookie("http://localhost", "cookie", "biscuit");
+ InternetSetCookieA("http://localhost", "cookie", "biscuit");
- req = HttpOpenRequest(con, NULL, "/testC", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ req = HttpOpenRequestA(con, NULL, "/testC", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
buffer[0] = 0;
size = sizeof(buffer);
SetLastError(0xdeadbeef);
- ret = HttpQueryInfo(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
error = GetLastError();
ok(!ret, "HttpQueryInfo succeeded\n");
ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %u expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
- ret = HttpAddRequestHeaders(req, "Cookie: cookie=not biscuit\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ret = HttpAddRequestHeadersA(req, "Cookie: cookie=not biscuit\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
ok(ret, "HttpAddRequestHeaders failed: %u\n", GetLastError());
buffer[0] = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ 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 = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
test_status_code(req, 200);
buffer[0] = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ 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);
- InternetCloseHandle(con);
- InternetCloseHandle(ses);
-}
-static void test_basic_authentication(int port)
-{
- HINTERNET session, connect, request;
- BOOL ret;
+ InternetSetCookieA("http://localhost/testCCCC", "subcookie", "data");
- session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(session != NULL, "InternetOpen failed\n");
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
- connect = InternetConnect(session, "localhost", port, "user", "pwd", INTERNET_SERVICE_HTTP, 0, 0);
- ok(connect != NULL, "InternetConnect failed\n");
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
- request = HttpOpenRequest(connect, NULL, "/test3", NULL, NULL, NULL, 0, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1/abc", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
- test_status_code(request, 200);
- test_request_flags(request, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
- InternetCloseHandle(request);
- InternetCloseHandle(connect);
- InternetCloseHandle(session);
+ 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);
}
-static void test_premature_disconnect(int port)
+static void test_basic_authentication(int port)
{
HINTERNET session, connect, request;
- DWORD err;
BOOL ret;
- session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(session != NULL, "InternetOpen failed\n");
- connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ connect = InternetConnectA(session, "localhost", port, "user", "pwd", INTERNET_SERVICE_HTTP, 0, 0);
ok(connect != NULL, "InternetConnect failed\n");
- request = HttpOpenRequest(connect, NULL, "/premature_disconnect", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ request = HttpOpenRequestA(connect, NULL, "/test3", NULL, NULL, NULL, 0, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+
+ test_status_code(request, 200);
+ test_request_flags(request, 0);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+}
+
+static void test_premature_disconnect(int port)
+{
+ test_request_t req;
+ DWORD err;
+ BOOL ret;
+
+ open_simple_request(&req, "localhost", port, NULL, "/premature_disconnect");
+
SetLastError(0xdeadbeef);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
err = GetLastError();
todo_wine ok(!ret, "HttpSendRequest succeeded\n");
todo_wine ok(err == ERROR_HTTP_INVALID_SERVER_RESPONSE, "got %u\n", err);
- InternetCloseHandle(request);
- InternetCloseHandle(connect);
- InternetCloseHandle(session);
+ close_request(&req);
}
static void test_invalid_response_headers(int port)
{
- HINTERNET session, connect, request;
+ test_request_t req;
DWORD size;
BOOL ret;
char buffer[256];
- session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(session != NULL, "InternetOpen failed\n");
-
- connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(connect != NULL, "InternetConnect failed\n");
-
- request = HttpOpenRequest(connect, NULL, "/testE", NULL, NULL, NULL, 0, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
+ open_simple_request(&req, "localhost", port, NULL, "/testE");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- test_status_code(request, 401);
- test_request_flags(request, 0);
+ test_status_code(req.request, 401);
+ test_request_flags(req.request, 0);
buffer[0] = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo( request, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "HTTP/1.0 401 Anonymous requests or requests on unsecure channel are not allowed"),
"headers wrong \"%s\"\n", buffer);
buffer[0] = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo( request, HTTP_QUERY_SERVER, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_SERVER, buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
ok(!strcmp(buffer, "winetest"), "server wrong \"%s\"\n", buffer);
- InternetCloseHandle(request);
- InternetCloseHandle(connect);
- InternetCloseHandle(session);
+ close_request(&req);
}
static void test_response_without_headers(int port)
{
- HINTERNET hi, hc, hr;
+ test_request_t req;
DWORD r, count, size;
char buffer[1024];
- SetLastError(0xdeadbeef);
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(hi != NULL, "open failed %u\n", GetLastError());
-
- SetLastError(0xdeadbeef);
- hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(hc != NULL, "connect failed %u\n", GetLastError());
+ open_simple_request(&req, "localhost", port, NULL, "/testG");
- SetLastError(0xdeadbeef);
- hr = HttpOpenRequest(hc, NULL, "/testG", NULL, NULL, NULL, 0, 0);
- ok(hr != NULL, "HttpOpenRequest failed %u\n", GetLastError());
+ test_request_flags(req.request, INTERNET_REQFLAG_NO_HEADERS);
- test_request_flags(hr, INTERNET_REQFLAG_NO_HEADERS);
-
- SetLastError(0xdeadbeef);
- r = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ r = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
ok(r, "HttpSendRequest failed %u\n", GetLastError());
- test_request_flags_todo(hr, INTERNET_REQFLAG_NO_HEADERS);
+ test_request_flags_todo(req.request, INTERNET_REQFLAG_NO_HEADERS);
count = 0;
memset(buffer, 0, sizeof buffer);
- SetLastError(0xdeadbeef);
- r = InternetReadFile(hr, buffer, sizeof buffer, &count);
+ r = InternetReadFile(req.request, buffer, sizeof buffer, &count);
ok(r, "InternetReadFile failed %u\n", GetLastError());
todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
- test_status_code(hr, 200);
- test_request_flags_todo(hr, INTERNET_REQFLAG_NO_HEADERS);
+ test_status_code(req.request, 200);
+ test_request_flags_todo(req.request, INTERNET_REQFLAG_NO_HEADERS);
buffer[0] = 0;
size = sizeof(buffer);
- SetLastError(0xdeadbeef);
- r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, NULL );
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_STATUS_TEXT, buffer, &size, NULL );
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
buffer[0] = 0;
size = sizeof(buffer);
- SetLastError(0xdeadbeef);
- r = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &size, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_VERSION, buffer, &size, NULL);
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
buffer[0] = 0;
size = sizeof(buffer);
- SetLastError(0xdeadbeef);
- r = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
+ r = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
ok(r, "HttpQueryInfo failed %u\n", GetLastError());
ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
- InternetCloseHandle(hr);
- InternetCloseHandle(hc);
- InternetCloseHandle(hi);
+ close_request(&req);
}
-static void test_HttpQueryInfo(int port)
+static void test_head_request(int port)
{
- HINTERNET hi, hc, hr;
- DWORD size, index;
- char buffer[1024];
+ DWORD len, content_length;
+ test_request_t req;
+ BYTE buf[100];
BOOL ret;
- hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(hi != NULL, "InternetOpen failed\n");
+ open_simple_request(&req, "localhost", port, "HEAD", "/test_head");
- hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(hc != NULL, "InternetConnect failed\n");
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
- hr = HttpOpenRequest(hc, NULL, "/testD", NULL, NULL, NULL, 0, 0);
- ok(hr != NULL, "HttpOpenRequest failed\n");
+ len = sizeof(content_length);
+ content_length = -1;
+ ret = HttpQueryInfoA(req.request, 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.request, buf, sizeof(buf), &len);
+ ok(ret, "InternetReadFile failed: %u\n", GetLastError());
+
+ len = -1;
+ ret = InternetReadFile(req.request, buf, sizeof(buf), &len);
+ ok(ret, "InternetReadFile failed: %u\n", GetLastError());
+
+ close_request(&req);
+}
+
+static void test_HttpQueryInfo(int port)
+{
+ test_request_t req;
+ DWORD size, index, error;
+ char buffer[1024];
+ BOOL ret;
+
+ open_simple_request(&req, "localhost", port, NULL, "/testD");
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, &index);
- ok(!ret && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfo failed %u\n", GetLastError());
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_STATUS_TEXT, buffer, &size, &index);
+ error = GetLastError();
+ ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
+ if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "got %u expected ERROR_HTTP_HEADER_NOT_FOUND\n", error);
- ret = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed\n");
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 1, "expected 1 got %u\n", index);
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_DATE | HTTP_QUERY_FLAG_SYSTEMTIME, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_DATE | HTTP_QUERY_FLAG_SYSTEMTIME, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 1, "expected 1 got %u\n", index);
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 0, "expected 0 got %u\n", index);
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 0, "expected 0 got %u\n", index);
index = 0xdeadbeef; /* invalid start index */
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS, buffer, &size, &index);
todo_wine ok(!ret, "HttpQueryInfo should have failed\n");
todo_wine ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
"Expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS_CRLF, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 0, "expected 0 got %u\n", index);
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_STATUS_TEXT, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 0, "expected 0 got %u\n", index);
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_VERSION, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 0, "expected 0 got %u\n", index);
- test_status_code(hr, 200);
+ test_status_code(req.request, 200);
index = 0xdeadbeef;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_FORWARDED, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_FORWARDED, buffer, &size, &index);
ok(!ret, "HttpQueryInfo succeeded\n");
ok(index == 0xdeadbeef, "expected 0xdeadbeef got %u\n", index);
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_SERVER, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_SERVER, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 1, "expected 1 got %u\n", index);
index = 0;
size = sizeof(buffer);
strcpy(buffer, "Server");
- ret = HttpQueryInfo(hr, HTTP_QUERY_CUSTOM, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_CUSTOM, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 1, "expected 1 got %u\n", index);
index = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_SET_COOKIE, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_SET_COOKIE, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 1, "expected 1 got %u\n", index);
size = sizeof(buffer);
- ret = HttpQueryInfo(hr, HTTP_QUERY_SET_COOKIE, buffer, &size, &index);
+ ret = HttpQueryInfoA(req.request, HTTP_QUERY_SET_COOKIE, buffer, &size, &index);
ok(ret, "HttpQueryInfo failed %u\n", GetLastError());
ok(index == 2, "expected 2 got %u\n", index);
- InternetCloseHandle(hr);
- InternetCloseHandle(hc);
- InternetCloseHandle(hi);
+ close_request(&req);
}
static void test_options(int port)
DWORD_PTR ctx;
BOOL ret;
- ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
SetLastError(0xdeadbeef);
- ret = InternetSetOption(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, 0);
+ ret = InternetSetOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, 0);
error = GetLastError();
ok(!ret, "InternetSetOption succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
SetLastError(0xdeadbeef);
- ret = InternetSetOption(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, sizeof(ctx));
+ ret = InternetSetOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, sizeof(ctx));
ok(!ret, "InternetSetOption succeeded\n");
error = GetLastError();
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
SetLastError(0xdeadbeef);
- ret = InternetSetOption(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, 0);
+ ret = InternetSetOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, 0);
ok(!ret, "InternetSetOption succeeded\n");
error = GetLastError();
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
ctx = 1;
- ret = InternetSetOption(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
+ ret = InternetSetOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
ok(ret, "InternetSetOption failed %u\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = InternetQueryOption(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, NULL);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, NULL);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
SetLastError(0xdeadbeef);
- ret = InternetQueryOption(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, NULL);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, NULL);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
size = 0;
SetLastError(0xdeadbeef);
- ret = InternetQueryOption(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, &size);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, NULL, &size);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
size = sizeof(ctx);
SetLastError(0xdeadbeef);
- ret = InternetQueryOption(NULL, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ret = InternetQueryOptionA(NULL, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %u\n", error);
ctx = 0xdeadbeef;
size = sizeof(ctx);
- ret = InternetQueryOption(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
ok(ret, "InternetQueryOption failed %u\n", GetLastError());
ok(ctx == 1, "expected 1 got %lu\n", ctx);
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(con != NULL, "InternetConnect failed\n");
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnect failed\n");
+
+ ctx = 0xdeadbeef;
+ size = sizeof(ctx);
+ ret = InternetQueryOptionA(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+ ok(ctx == 0, "expected 0 got %lu\n", ctx);
+
+ ctx = 2;
+ ret = InternetSetOptionA(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
+ ok(ret, "InternetSetOption failed %u\n", GetLastError());
+
+ ctx = 0xdeadbeef;
+ size = sizeof(ctx);
+ ret = InternetQueryOptionA(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+ ok(ctx == 2, "expected 2 got %lu\n", ctx);
+
+ req = HttpOpenRequestA(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ctx = 0xdeadbeef;
+ size = sizeof(ctx);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+ ok(ctx == 0, "expected 0 got %lu\n", ctx);
+
+ ctx = 3;
+ ret = InternetSetOptionA(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
+ ok(ret, "InternetSetOption failed %u\n", GetLastError());
+
+ ctx = 0xdeadbeef;
+ size = sizeof(ctx);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
+ ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+ ok(ctx == 3, "expected 3 got %lu\n", ctx);
+
+ size = sizeof(idsi);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO, &idsi, &size);
+ ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+
+ size = 0;
+ SetLastError(0xdeadbeef);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, NULL, &size);
+ error = GetLastError();
+ ok(!ret, "InternetQueryOption succeeded\n");
+ ok(error == ERROR_INTERNET_INVALID_OPERATION, "expected ERROR_INTERNET_INVALID_OPERATION, got %u\n", error);
+
+ /* INTERNET_OPTION_PROXY */
+ SetLastError(0xdeadbeef);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, NULL);
+ error = GetLastError();
+ ok(!ret, "InternetQueryOption succeeded\n");
+ ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
+
+ SetLastError(0xdeadbeef);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, &ctx, NULL);
+ error = GetLastError();
+ ok(!ret, "InternetQueryOption succeeded\n");
+ ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
+
+ size = 0;
+ SetLastError(0xdeadbeef);
+ ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, &size);
+ error = GetLastError();
+ ok(!ret, "InternetQueryOption succeeded\n");
+ ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
+ ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+}
+
+typedef struct {
+ const char *response_text;
+ int status_code;
+ const char *status_text;
+ const char *raw_headers;
+} http_status_test_t;
+
+static const http_status_test_t http_status_tests[] = {
+ {
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 1\r\n"
+ "\r\nx",
+ 200,
+ "OK"
+ },
+ {
+ "HTTP/1.1 404 Fail\r\n"
+ "Content-Length: 1\r\n"
+ "\r\nx",
+ 404,
+ "Fail"
+ },
+ {
+ "HTTP/1.1 200\r\n"
+ "Content-Length: 1\r\n"
+ "\r\nx",
+ 200,
+ ""
+ },
+ {
+ "HTTP/1.1 410 \r\n"
+ "Content-Length: 1\r\n"
+ "\r\nx",
+ 410,
+ ""
+ }
+};
+
+static void test_http_status(int port)
+{
+ test_request_t req;
+ char buf[1000];
+ DWORD i, size;
+ BOOL res;
+
+ for(i=0; i < sizeof(http_status_tests)/sizeof(*http_status_tests); i++) {
+ send_buffer = http_status_tests[i].response_text;
+
+ open_simple_request(&req, "localhost", port, NULL, "/send_from_buffer");
+
+ res = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ ok(res, "HttpSendRequest failed\n");
+
+ test_status_code(req.request, http_status_tests[i].status_code);
+
+ size = sizeof(buf);
+ res = HttpQueryInfoA(req.request, HTTP_QUERY_STATUS_TEXT, buf, &size, NULL);
+ ok(res, "HttpQueryInfo failed: %u\n", GetLastError());
+ ok(!strcmp(buf, http_status_tests[i].status_text), "[%u] Unexpected status text \"%s\", expected \"%s\"\n",
+ i, buf, http_status_tests[i].status_text);
+
+ close_request(&req);
+ }
+}
+
+static void test_cache_control_verb(int port)
+{
+ HINTERNET session, connect, request;
+ BOOL ret;
+
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(session != NULL, "InternetOpen failed\n");
+
+ connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, "RPC_OUT_DATA", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+ InternetCloseHandle(request);
+
+ request = HttpOpenRequestA(connect, "POST", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+ InternetCloseHandle(request);
+
+ request = HttpOpenRequestA(connect, "HEAD", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+ InternetCloseHandle(request);
+
+ request = HttpOpenRequestA(connect, "GET", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+ InternetCloseHandle(request);
+
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+}
+
+static void test_request_content_length(int port)
+{
+ char data[] = {'t','e','s','t'};
+ test_request_t req;
+ BOOL ret;
+
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+
+ open_simple_request(&req, "localhost", port, "POST", "/test_request_content_length");
+
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(req.request, 200);
+
+ SetEvent(hCompleteEvent);
+
+ ret = HttpSendRequestA(req.request, NULL, 0, data, sizeof(data));
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(req.request, 200);
+
+ SetEvent(hCompleteEvent);
+
+ close_request(&req);
+ CloseHandle(hCompleteEvent);
+}
+
+static void test_accept_encoding(int port)
+{
+ HINTERNET ses, con, req;
+ char buf[1000];
+ 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, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, "Accept-Encoding: gzip\r\n", ~0u, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed\n");
+
+ test_status_code(req, 200);
+ receive_simple_request(req, buf, sizeof(buf));
+ ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
+
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, "GET", "/echo_request", "HTTP/1.0", NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(req, "Accept-Encoding: gzip", ~0u, NULL, 0);
+ ok(ret, "HttpSendRequestA failed\n");
+
+ test_status_code(req, 200);
+ receive_simple_request(req, buf, sizeof(buf));
+ ok(strstr(buf, "Accept-Encoding: gzip") != NULL, "Accept-Encoding header not found in %s\n", buf);
+
+ 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", INTERNET_OPEN_TYPE_DIRECT, 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", 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, "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_async_read(int port)
+{
+ HINTERNET ses, con, req;
+ INTERNET_BUFFERSA ib;
+ char buffer[0x100];
+ DWORD pending_reads;
+ DWORD res, count, bytes;
+ BOOL ret;
+
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+
+ /* test asynchronous InternetReadFileEx */
+ ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC );
+ ok( ses != NULL, "InternetOpenA failed\n" );
+ pInternetSetStatusCallbackA( ses, &callback );
+
+ SET_EXPECT( INTERNET_STATUS_HANDLE_CREATED );
+ con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
+ ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
+ CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_EXPECT( INTERNET_STATUS_HANDLE_CREATED );
+ req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
+ ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
+ CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_OPTIONAL( INTERNET_STATUS_COOKIE_SENT );
+ SET_OPTIONAL( INTERNET_STATUS_DETECTING_PROXY );
+ SET_EXPECT( INTERNET_STATUS_CONNECTING_TO_SERVER );
+ SET_EXPECT( INTERNET_STATUS_CONNECTED_TO_SERVER );
+ SET_EXPECT( INTERNET_STATUS_SENDING_REQUEST );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_SENT );
+ SET_EXPECT( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_RESPONSE_RECEIVED );
+ SET_OPTIONAL( INTERNET_STATUS_CLOSING_CONNECTION );
+ SET_OPTIONAL( INTERNET_STATUS_CONNECTION_CLOSED );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE );
+
+ SetLastError( 0xdeadbeef );
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
+ ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+ WaitForSingleObject( hCompleteEvent, INFINITE );
+ ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
+
+ CLEAR_NOTIFIED( INTERNET_STATUS_COOKIE_SENT );
+ CLEAR_NOTIFIED( INTERNET_STATUS_DETECTING_PROXY );
+ CHECK_NOTIFIED( INTERNET_STATUS_CONNECTING_TO_SERVER );
+ CHECK_NOTIFIED( INTERNET_STATUS_CONNECTED_TO_SERVER );
+ CHECK_NOTIFIED( INTERNET_STATUS_SENDING_REQUEST );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_SENT );
+ CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ CHECK_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ CLEAR_NOTIFIED( INTERNET_STATUS_CLOSING_CONNECTION );
+ CLEAR_NOTIFIED( INTERNET_STATUS_CONNECTION_CLOSED );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_COMPLETE );
+
+ pending_reads = 0;
+ memset( &ib, 0, sizeof(ib) );
+ memset( buffer, 0, sizeof(buffer) );
+ ib.dwStructSize = sizeof(ib);
+ for (count = 0; count < sizeof(buffer); count += ib.dwBufferLength)
+ {
+ ib.lpvBuffer = buffer + count;
+ ib.dwBufferLength = min(16, sizeof(buffer) - count);
+
+ SET_EXPECT( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_RESPONSE_RECEIVED );
+
+ ret = InternetReadFileExA( req, &ib, 0, 0xdeadbeef );
+ if (!count) /* the first part should arrive immediately */
+ ok( ret, "InternetReadFileExA failed %u\n", GetLastError() );
+ if (!ret)
+ {
+ ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+ CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE );
+ if (!pending_reads++)
+ {
+ res = WaitForSingleObject( hCompleteEvent, 0 );
+ ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res );
+ SetEvent( conn_wait_event );
+ }
+ res = WaitForSingleObject( hCompleteEvent, INFINITE );
+ ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res );
+ ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
+ todo_wine_if( pending_reads > 1 )
+ ok( ib.dwBufferLength != 0, "expected ib.dwBufferLength != 0\n" );
+ CHECK_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_COMPLETE );
+ }
+
+ CLEAR_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ CLEAR_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ if (!ib.dwBufferLength) break;
+ }
+
+ todo_wine
+ ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads );
+ ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
+ close_async_handle( ses, hCompleteEvent, 2 );
+ ResetEvent( conn_wait_event );
+
+ /* test asynchronous InternetReadFile */
+ ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC );
+ ok( ses != NULL, "InternetOpenA failed\n" );
+ pInternetSetStatusCallbackA( ses, &callback );
+
+ SET_EXPECT( INTERNET_STATUS_HANDLE_CREATED );
+ con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef );
+ ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
+ CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_EXPECT( INTERNET_STATUS_HANDLE_CREATED );
+ req = HttpOpenRequestA( con, "GET", "/async_read", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef );
+ ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
+ CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_OPTIONAL( INTERNET_STATUS_COOKIE_SENT );
+ SET_OPTIONAL( INTERNET_STATUS_DETECTING_PROXY );
+ SET_EXPECT( INTERNET_STATUS_CONNECTING_TO_SERVER );
+ SET_EXPECT( INTERNET_STATUS_CONNECTED_TO_SERVER );
+ SET_EXPECT( INTERNET_STATUS_SENDING_REQUEST );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_SENT );
+ SET_EXPECT( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_RESPONSE_RECEIVED );
+ SET_OPTIONAL( INTERNET_STATUS_CLOSING_CONNECTION );
+ SET_OPTIONAL( INTERNET_STATUS_CONNECTION_CLOSED );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE );
+
+ SetLastError( 0xdeadbeef );
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" );
+ ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+ WaitForSingleObject( hCompleteEvent, INFINITE );
+ ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
+
+ CLEAR_NOTIFIED( INTERNET_STATUS_COOKIE_SENT );
+ CLEAR_NOTIFIED( INTERNET_STATUS_DETECTING_PROXY );
+ CHECK_NOTIFIED( INTERNET_STATUS_CONNECTING_TO_SERVER );
+ CHECK_NOTIFIED( INTERNET_STATUS_CONNECTED_TO_SERVER );
+ CHECK_NOTIFIED( INTERNET_STATUS_SENDING_REQUEST );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_SENT );
+ CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ CHECK_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ CLEAR_NOTIFIED( INTERNET_STATUS_CLOSING_CONNECTION );
+ CLEAR_NOTIFIED( INTERNET_STATUS_CONNECTION_CLOSED );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_COMPLETE );
+
+ pending_reads = 0;
+ memset( buffer, 0, sizeof(buffer) );
+ for (count = 0; count < sizeof(buffer); count += bytes)
+ {
+ SET_EXPECT( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_RESPONSE_RECEIVED );
+
+ bytes = 0xdeadbeef;
+ ret = InternetReadFile( req, buffer + count, min(16, sizeof(buffer) - count), &bytes );
+ if (!count) /* the first part should arrive immediately */
+ ok( ret, "InternetReadFile failed %u\n", GetLastError() );
+ if (!ret)
+ {
+ ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+ ok( bytes == 0, "expected 0, got %u\n", bytes );
+ todo_wine
+ CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE );
+ if (!pending_reads++)
+ {
+ res = WaitForSingleObject( hCompleteEvent, 0 );
+ ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res );
+ SetEvent( conn_wait_event );
+ }
+ res = WaitForSingleObject( hCompleteEvent, INFINITE );
+ ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res );
+ ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error );
+ todo_wine_if( pending_reads > 1 )
+ ok( bytes != 0, "expected bytes != 0\n" );
+ CHECK_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ CHECK_NOTIFIED( INTERNET_STATUS_REQUEST_COMPLETE );
+ }
+
+ CLEAR_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
+ CLEAR_NOTIFIED( INTERNET_STATUS_RESPONSE_RECEIVED );
+ if (!bytes) break;
+ }
+
+ todo_wine
+ ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads );
+ ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
+ close_async_handle( ses, hCompleteEvent, 2 );
+
+ CloseHandle( hCompleteEvent );
+ CloseHandle( conn_wait_event );
+}
+
+static void server_send_string(const char *msg)
+{
+ send(server_socket, msg, strlen(msg), 0);
+}
+
+static void WINAPI readex_callback(HINTERNET handle, DWORD_PTR context, DWORD status, void *info, DWORD info_size)
+{
+ switch(status) {
+ case INTERNET_STATUS_RECEIVING_RESPONSE:
+ case INTERNET_STATUS_RESPONSE_RECEIVED:
+ break;
+ default:
+ callback(handle, context, status, info, info_size);
+ }
+}
+
+static void open_read_test_request(int port, test_request_t *req, const char *response)
+{
+ BOOL ret;
+
+ req->session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ok(req->session != NULL, "InternetOpenA failed\n");
+ pInternetSetStatusCallbackA(req->session, readex_callback);
+
+ SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
+ req->connection = InternetConnectA(req->session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0xdeadbeef);
+ ok(req->connection != NULL, "InternetConnectA failed %u\n", GetLastError());
+ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
+ req->request = HttpOpenRequestA(req->connection, "GET", "/socket", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef);
+ ok(req->request != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+ CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED );
+
+ SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
+ SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
+ SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
+ SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
+ SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
+
+ SetLastError(0xdeadbeef);
+ ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0);
+ ok(!ret, "HttpSendRequestA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError());
+ ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error);
+
+ WaitForSingleObject(server_req_rec_event, INFINITE);
+
+ CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
+ CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
+ CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
+
+ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ server_send_string(response);
+ WaitForSingleObject(hCompleteEvent, INFINITE);
+
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+}
+
+#define readex_expect_sync_data_len(a,b,c,d,e,f) _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f)
+static void _readex_expect_sync_data_len(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf,
+ DWORD buf_size, const char *exdata, DWORD len)
+{
+ BOOL ret;
+
+ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ memset(buf->lpvBuffer, 0xff, buf_size);
+ buf->dwBufferLength = buf_size;
+ ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
+ ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError());
+ ok_(__FILE__,line)(buf->dwBufferLength == len, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, len);
+ if(len && exdata)
+ ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "Unexpected data\n");
+
+ CLEAR_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+}
+
+#define readex_expect_sync_data(a,b,c,d,e) _readex_expect_sync_data(__LINE__,a,b,c,d,e)
+static void _readex_expect_sync_data(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf,
+ DWORD buf_size, const char *exdata)
+{
+ _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata));
+}
+
+static void send_response_and_wait(const char *response, BOOL close_connection, INTERNET_BUFFERSW *buf)
+{
+ DWORD orig_size = buf->dwBufferLength;
+
+ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ if(response)
+ server_send_string(response);
+
+ if(close_connection) {
+ char c;
+ SetEvent(conn_wait_event);
+ recv(server_socket, &c, 1, 0);
+ }
+
+ WaitForSingleObject(hCompleteEvent, INFINITE);
+
+ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+
+ /* If IRF_NO_WAIT is used, buffer is not changed. */
+ ok(buf->dwBufferLength == orig_size, "dwBufferLength = %u\n", buf->dwBufferLength);
+ ok(!*(int*)buf->lpvBuffer, "buffer data changed\n");
+}
+
+static void send_response_len_and_wait(unsigned len, BOOL close_connection, INTERNET_BUFFERSW *buf)
+{
+ char *response;
+
+ response = HeapAlloc(GetProcessHeap(), 0, len+1);
+ memset(response, 'x', len);
+ response[len] = 0;
+ send_response_and_wait(response, close_connection, buf);
+ HeapFree(GetProcessHeap(), 0, response);
+}
+
+static void readex_expect_async(HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size)
+{
+ BOOL ret;
+
+ memset(buf->lpvBuffer, 0, buf_size);
+ buf->dwBufferLength = buf_size;
+ ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
+ ok(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError());
+ ok(buf->dwBufferLength == buf_size, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, buf_size);
+ ok(!*(int*)buf->lpvBuffer, "buffer data changed\n");
+}
+
+#define expect_data_available(a,b) _expect_data_available(__LINE__,a,b)
+static DWORD _expect_data_available(unsigned line, HINTERNET req, int exsize)
+{
+ DWORD size = 0;
+ BOOL res;
+
+ res = InternetQueryDataAvailable(req, &size, 0, 0);
+ ok_(__FILE__,line)(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
+ if(exsize != -1)
+ ok_(__FILE__,line)(size == exsize, "size = %u, expected %u\n", size, exsize);
- ctx = 0xdeadbeef;
- size = sizeof(ctx);
- ret = InternetQueryOption(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
- ok(ret, "InternetQueryOption failed %u\n", GetLastError());
- ok(ctx == 0, "expected 0 got %lu\n", ctx);
+ return size;
+}
- ctx = 2;
- ret = InternetSetOption(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
- ok(ret, "InternetSetOption failed %u\n", GetLastError());
+static void test_http_read(int port)
+{
+ INTERNET_BUFFERSW ib;
+ test_request_t req;
+ char buf[24000];
+ DWORD avail;
- ctx = 0xdeadbeef;
- size = sizeof(ctx);
- ret = InternetQueryOption(con, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
- ok(ret, "InternetQueryOption failed %u\n", GetLastError());
- ok(ctx == 2, "expected 2 got %lu\n", ctx);
+ if(!is_ie7plus)
+ return;
- req = HttpOpenRequest(con, NULL, "/test1", NULL, NULL, NULL, 0, 0);
- ok(req != NULL, "HttpOpenRequest failed\n");
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL);
- ctx = 0xdeadbeef;
- size = sizeof(ctx);
- ret = InternetQueryOption(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
- ok(ret, "InternetQueryOption failed %u\n", GetLastError());
- ok(ctx == 0, "expected 0 got %lu\n", ctx);
+ trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n");
- ctx = 3;
- ret = InternetSetOption(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, sizeof(ctx));
- ok(ret, "InternetSetOption failed %u\n", GetLastError());
+ open_read_test_request(port, &req,
+ "HTTP/1.1 200 OK\r\n"
+ "Server: winetest\r\n"
+ "\r\n"
+ "xx");
- ctx = 0xdeadbeef;
- size = sizeof(ctx);
- ret = InternetQueryOption(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size);
- ok(ret, "InternetQueryOption failed %u\n", GetLastError());
- ok(ctx == 3, "expected 3 got %lu\n", ctx);
+ memset(&ib, 0, sizeof(ib));
+ ib.dwStructSize = sizeof(ib);
+ ib.lpvBuffer = buf;
- size = sizeof(idsi);
- ret = InternetQueryOption(req, INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO, &idsi, &size);
- ok(ret, "InternetQueryOption failed %u\n", GetLastError());
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xx");
- size = 0;
- SetLastError(0xdeadbeef);
- ret = InternetQueryOption(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, NULL, &size);
- error = GetLastError();
- ok(!ret, "InternetQueryOption succeeded\n");
- ok(error == ERROR_INTERNET_INVALID_OPERATION, "expected ERROR_INTERNET_INVALID_OPERATION, got %u\n", error);
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
+ send_response_and_wait("1234567890", FALSE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 5, "12345");
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "67890");
- /* INTERNET_OPTION_PROXY */
- SetLastError(0xdeadbeef);
- ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, NULL);
- error = GetLastError();
- ok(!ret, "InternetQueryOption succeeded\n");
- ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
+ send_response_and_wait("12345", TRUE, &ib);
- SetLastError(0xdeadbeef);
- ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, &ctx, NULL);
- error = GetLastError();
- ok(!ret, "InternetQueryOption succeeded\n");
- ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345");
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "");
- size = 0;
- SetLastError(0xdeadbeef);
- ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, &size);
- error = GetLastError();
- ok(!ret, "InternetQueryOption succeeded\n");
- ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
- ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
+ close_async_handle(req.session, hCompleteEvent, 2);
- InternetCloseHandle(req);
- InternetCloseHandle(con);
- InternetCloseHandle(ses);
-}
+ open_read_test_request(port, &req,
+ "HTTP/1.1 200 OK\r\n"
+ "Server: winetest\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "\r\n"
+ "9\r\n123456789");
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123456789");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
-typedef struct {
- const char *response_text;
- int status_code;
- const char *status_text;
- const char *raw_headers;
-} http_status_test_t;
+ send_response_and_wait("\r\n1\r\na\r\n1\r\nb\r", FALSE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
-static const http_status_test_t http_status_tests[] = {
- {
- "HTTP/1.1 200 OK\r\n"
- "Content-Length: 1\r\n"
- "\r\nx",
- 200,
- "OK"
- },
- {
- "HTTP/1.1 404 Fail\r\n"
- "Content-Length: 1\r\n"
- "\r\nx",
- 404,
- "Fail"
- },
- {
- "HTTP/1.1 200\r\n"
- "Content-Length: 1\r\n"
- "\r\nx",
- 200,
- ""
- },
- {
- "HTTP/1.1 410 \r\n"
- "Content-Length: 1\r\n"
- "\r\nx",
- 410,
- ""
- }
-};
+ send_response_and_wait("\n3\r\nab", FALSE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
-static void test_http_status(int port)
-{
- HINTERNET ses, con, req;
- char buf[1000];
- DWORD i, size;
- BOOL res;
+ send_response_and_wait("c", FALSE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "c");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
- for(i=0; i < sizeof(http_status_tests)/sizeof(*http_status_tests); i++) {
- send_buffer = http_status_tests[i].response_text;
+ send_response_and_wait("\r\n1\r\nx\r\n0\r\n\r\n", TRUE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x");
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "");
- ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(ses != NULL, "InternetOpen failed\n");
+ close_async_handle(req.session, hCompleteEvent, 2);
- con = InternetConnect(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(con != NULL, "InternetConnect failed\n");
+ open_read_test_request(port, &req,
+ "HTTP/1.1 200 OK\r\n"
+ "Server: winetest\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "\r\n"
+ "3\r\n123\r\n");
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
- req = HttpOpenRequest(con, NULL, "/send_from_buffer", NULL, NULL, NULL, 0, 0);
- ok(req != NULL, "HttpOpenRequest failed\n");
+ send_response_and_wait("0\r\n\r\n", TRUE, &ib);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "");
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
- ok(res, "HttpSendRequest failed\n");
+ close_async_handle(req.session, hCompleteEvent, 2);
- test_status_code(req, http_status_tests[i].status_code);
+ trace("Testing InternetQueryDataAvailable...\n");
- size = sizeof(buf);
- res = HttpQueryInfo(req, HTTP_QUERY_STATUS_TEXT, buf, &size, NULL);
- ok(res, "HttpQueryInfo failed: %u\n", GetLastError());
- ok(!strcmp(buf, http_status_tests[i].status_text), "[%u] Unexpected status text \"%s\", expected \"%s\"\n",
- i, buf, http_status_tests[i].status_text);
+ open_read_test_request(port, &req,
+ "HTTP/1.1 200 OK\r\n"
+ "Server: winetest\r\n"
+ "\r\n"
+ "123");
+ expect_data_available(req.request, 3);
+ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123");
+ readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf));
- InternetCloseHandle(req);
- InternetCloseHandle(con);
- InternetCloseHandle(ses);
- }
+ send_response_len_and_wait(20000, TRUE, &ib);
+ avail = expect_data_available(req.request, -1);
+ ok(avail < 17000, "avail = %u\n", avail);
+
+ SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION);
+ SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED);
+ close_async_handle(req.session, hCompleteEvent, 2);
+ todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
+ todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
+
+ CloseHandle(hCompleteEvent);
+ CloseHandle(conn_wait_event);
+ CloseHandle(server_req_rec_event);
}
-static void test_cache_control_verb(int port)
+static void test_long_url(int port)
{
- HINTERNET session, connect, request;
+ char long_path[INTERNET_MAX_PATH_LENGTH*2] = "/echo_request?";
+ char buf[sizeof(long_path)*2], url[sizeof(buf)];
+ test_request_t req;
+ DWORD size, len;
BOOL ret;
- session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(session != NULL, "InternetOpen failed\n");
+ if(!is_ie7plus)
+ return;
- connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(connect != NULL, "InternetConnect failed\n");
+ memset(long_path+strlen(long_path), 'x', sizeof(long_path)-strlen(long_path));
+ long_path[sizeof(long_path)-1] = 0;
+ open_simple_request(&req, "localhost", port, NULL, long_path);
- request = HttpOpenRequest(connect, "RPC_OUT_DATA", "/test_cache_control_verb", NULL, NULL, NULL,
- INTERNET_FLAG_NO_CACHE_WRITE, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- test_status_code(request, 200);
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+ test_status_code(req.request, 200);
- request = HttpOpenRequest(connect, "POST", "/test_cache_control_verb", NULL, NULL, NULL,
- INTERNET_FLAG_NO_CACHE_WRITE, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- test_status_code(request, 200);
+ receive_simple_request(req.request, buf, sizeof(buf));
+ ok(strstr(buf, long_path) != NULL, "long pathnot found in %s\n", buf);
- request = HttpOpenRequest(connect, "HEAD", "/test_cache_control_verb", NULL, NULL, NULL,
- INTERNET_FLAG_NO_CACHE_WRITE, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- test_status_code(request, 200);
+ sprintf(url, "http://localhost:%u%s", port, long_path);
- request = HttpOpenRequest(connect, "GET", "/test_cache_control_verb", NULL, NULL, NULL,
- INTERNET_FLAG_NO_CACHE_WRITE, 0);
- ok(request != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- test_status_code(request, 200);
+ size = sizeof(buf);
+ ret = InternetQueryOptionA(req.request, INTERNET_OPTION_URL, buf, &size);
+ ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
+ len = strlen(url);
+ ok(size == len, "size = %u, expected %u\n", size, len);
+ ok(!strcmp(buf, url), "Wrong URL %s, expected %s\n", buf, url);
- InternetCloseHandle(request);
- InternetCloseHandle(connect);
- InternetCloseHandle(session);
+ close_request(&req);
}
static void test_http_connection(void)
HANDLE hThread;
DWORD id = 0, r;
- si.hEvent = CreateEvent(NULL, 0, 0, NULL);
+ si.hEvent = CreateEventW(NULL, 0, 0, NULL);
si.port = 7531;
hThread = CreateThread(NULL, 0, server_thread, (LPVOID) &si, 0, &id);
test_basic_request(si.port, "GET", "/test6");
test_basic_request(si.port, "GET", "/testF");
test_connection_header(si.port);
- test_http1_1(si.port);
+ test_header_override(si.port);
test_cookie_header(si.port);
test_basic_authentication(si.port);
test_invalid_response_headers(si.port);
test_response_without_headers(si.port);
test_HttpQueryInfo(si.port);
test_HttpSendRequestW(si.port);
- test_last_error(si.port);
test_options(si.port);
test_no_content(si.port);
test_conn_close(si.port);
test_premature_disconnect(si.port);
test_connection_closing(si.port);
test_cache_control_verb(si.port);
+ test_successive_HttpSendRequest(si.port);
+ test_head_request(si.port);
+ test_request_content_length(si.port);
+ test_accept_encoding(si.port);
+ test_basic_auth_credentials_reuse(si.port);
+ test_async_read(si.port);
+ test_http_read(si.port);
+ test_long_url(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
} cert_struct_test_t;
static const cert_struct_test_t test_winehq_org_cert = {
- "0mJuv1t-1CFypQkyTZwfvjHHBAbnUndG\r\n"
- "GT98380011\r\n"
- "See www.rapidssl.com/resources/cps (c)13\r\n"
- "Domain Control Validated - RapidSSL(R)\r\n"
"*.winehq.org",
"US\r\n"
- "\"GeoTrust, Inc.\"\r\n"
- "RapidSSL CA"
+ "GeoTrust Inc.\r\n"
+ "RapidSSL SHA256 CA"
};
static const cert_struct_test_t test_winehq_com_cert = {
memset(&info, 0x5, sizeof(info));
size = sizeof(info);
- res = InternetQueryOption(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, &info, &size);
+ res = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, &info, &size);
ok(res, "InternetQueryOption failed: %u\n", GetLastError());
ok(size == sizeof(info), "size = %u\n", size);
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);
}
CertFreeCertificateChain(chain);
}else {
ok_(__FILE__,line)(!res && GetLastError() == error,
- "InternetGetSecurityInfoByURLA returned: %x(%u), exected %u\n", res, GetLastError(), error);
+ "InternetGetSecurityInfoByURLA returned: %x(%u), expected %u\n", res, GetLastError(), error);
}
}
-#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)
static void test_security_flags(void)
{
+ INTERNET_CERTIFICATE_INFOA *cert;
HINTERNET ses, conn, req;
DWORD size, flags;
char buf[100];
trace("Testing security flags...\n");
- hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- ses = InternetOpen("WineTest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ses = InternetOpenA("WineTest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(ses != NULL, "InternetOpen failed\n");
pInternetSetStatusCallbackA(ses, &callback);
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
- req = HttpOpenRequest(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
+ req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
INTERNET_FLAG_SECURE|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE,
0xdeadbeef);
ok(req != NULL, "HttpOpenRequest failed\n");
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);
SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
WaitForSingleObject(hCompleteEvent, INFINITE);
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());
ok(res, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
- req = HttpOpenRequest(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
+ req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
INTERNET_FLAG_SECURE|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE,
0xdeadbeef);
ok(req != NULL, "HttpOpenRequest failed\n");
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
flags = INTERNET_ERROR_MASK_COMBINED_SEC_CERT|INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY;
- res = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&flags, sizeof(flags));
+ res = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&flags, sizeof(flags));
ok(res, "InternetQueryOption(INTERNET_OPTION_ERROR_MASK 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);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
WaitForSingleObject(hCompleteEvent, INFINITE);
ok(req_error == ERROR_INTERNET_SEC_CERT_REV_FAILED || broken(req_error == ERROR_INTERNET_SEC_CERT_ERRORS),
"req_error = %d\n", req_error);
- 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);
+ size = 0;
+ res = InternetQueryOptionW(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, NULL, &size);
+ ok(res || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
+ ok(size == sizeof(INTERNET_CERTIFICATE_INFOA), "size = %u\n", size);
+ cert = HeapAlloc(GetProcessHeap(), 0, size);
+ cert->lpszSubjectInfo = NULL;
+ cert->lpszIssuerInfo = NULL;
+ cert->lpszSignatureAlgName = (char *)0xdeadbeef;
+ cert->lpszEncryptionAlgName = (char *)0xdeadbeef;
+ cert->lpszProtocolName = (char *)0xdeadbeef;
+ cert->dwKeySize = 0xdeadbeef;
+ res = InternetQueryOptionW(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, cert, &size);
+ ok(res, "InternetQueryOption failed: %u\n", GetLastError());
+ if (res)
+ {
+ ok(cert->lpszSubjectInfo && strlen(cert->lpszSubjectInfo) > 1, "expected a non-empty subject name\n");
+ ok(cert->lpszIssuerInfo && strlen(cert->lpszIssuerInfo) > 1, "expected a non-empty issuer name\n");
+ ok(!cert->lpszSignatureAlgName, "unexpected signature algorithm name\n");
+ ok(!cert->lpszEncryptionAlgName, "unexpected encryption algorithm name\n");
+ ok(!cert->lpszProtocolName, "unexpected protocol name\n");
+ ok(cert->dwKeySize != 0xdeadbeef, "unexpected key size\n");
+ }
+ HeapFree(GetProcessHeap(), 0, cert);
+
+ 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);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
WaitForSingleObject(hCompleteEvent, INFINITE);
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);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY);
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
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());
/* Make another request, without setting security flags */
- ses = InternetOpen("WineTest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ses = InternetOpenA("WineTest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(ses != NULL, "InternetOpen failed\n");
pInternetSetStatusCallbackA(ses, &callback);
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
- req = HttpOpenRequest(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
+ req = HttpOpenRequestA(conn, "GET", "/tests/hello.html", NULL, NULL, NULL,
INTERNET_FLAG_SECURE|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE,
0xdeadbeef);
ok(req != NULL, "HttpOpenRequest failed\n");
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);
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
- res = HttpSendRequest(req, NULL, 0, NULL, 0);
+ res = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError());
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());
INTERNET_CERTIFICATE_INFOW *certificate_structW = NULL;
BOOL ret;
- ses = InternetOpen("Gizmo5", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+ ses = InternetOpenA("Gizmo5", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
- con = InternetConnect(ses, "test.winehq.org",
+ con = InternetConnectA(ses, "test.winehq.org",
INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- req = HttpOpenRequest(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
+ req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
INTERNET_FLAG_SECURE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
- ok(ret, "HttpSendRequest failed: %d\n", GetLastError());
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ 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 = InternetQueryOption(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size);
ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set\n");
- if (!winetest_interactive)
- {
- skip("test_cert_struct(req, &test_winehq_org_cert), ROSTESTS-121\n");
- }
- else
- {
- test_cert_struct(req, &test_winehq_org_cert);
- }
+ test_cert_struct(req, &test_winehq_org_cert);
/* Querying the same option through InternetQueryOptionW still results in
* ASCII strings being returned.
ok(ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER, "InternetQueryOption failed: %d\n", GetLastError());
ok(size == sizeof(INTERNET_CERTIFICATE_INFOW), "size = %d\n", size);
certificate_structW = HeapAlloc(GetProcessHeap(), 0, size);
- ret = InternetQueryOption(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
certificate_structW, &size);
certificate_structA = (INTERNET_CERTIFICATE_INFOA *)certificate_structW;
ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
INTERNET_FLAG_SECURE|INTERNET_FLAG_RELOAD, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
- ret = HttpSendRequest(req, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %d\n", GetLastError());
size = sizeof(flags);
- ret = InternetQueryOption(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size);
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size);
ok(ret, "InternetQueryOption failed: %d\n", GetLastError());
ok(flags & SECURITY_FLAG_SECURE, "expected secure flag to be set, got %x\n", flags);
}
HeapFree(GetProcessHeap(), 0, certificate_structW);
+done:
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
char buffer[64];
BOOL ret;
- ses = InternetOpen("Gizmo5", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+ ses = InternetOpenA("Gizmo5", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
- con = InternetConnect(ses, "test.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ con = InternetConnectA(ses, "test.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
- req = HttpOpenRequest(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, "GET", "/tests/hello.html", "HTTP/1.0", NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_USER_AGENT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req, HTTP_QUERY_USER_AGENT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
err = GetLastError();
ok(!ret, "HttpQueryInfo succeeded\n");
ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err);
- ret = HttpAddRequestHeaders(req, "User-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ ret = HttpAddRequestHeadersA(req, "User-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
ok(ret, "HttpAddRequestHeaders succeeded\n");
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_USER_AGENT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ 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);
- req = HttpOpenRequest(con, "GET", "/", "HTTP/1.0", NULL, NULL, 0, 0);
+ req = HttpOpenRequestA(con, "GET", "/", "HTTP/1.0", NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
err = GetLastError();
ok(!ret, "HttpQueryInfo succeeded\n");
ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err);
- ret = HttpAddRequestHeaders(req, "Accept: audio/*, image/*, text/*\r\nUser-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ ret = HttpAddRequestHeadersA(req, "Accept: audio/*, image/*, text/*\r\nUser-Agent: Gizmo Project\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
ok(ret, "HttpAddRequestHeaders failed\n");
buffer[0] = 0;
size = sizeof(buffer);
- ret = HttpQueryInfo(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
ok(!strcmp(buffer, "audio/*, image/*, text/*"), "got '%s' expected 'audio/*, image/*, text/*'\n", buffer);
char buffer[32];
BOOL ret;
- ses = InternetOpen("MERONG(0.9/;p)", INTERNET_OPEN_TYPE_DIRECT, "", "", 0);
- con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- req = HttpOpenRequest(con, "POST", "/post/post_action.php", "HTTP/1.0", "", types, INTERNET_FLAG_FORMS_SUBMIT, 0);
+ ses = InternetOpenA("MERONG(0.9/;p)", INTERNET_OPEN_TYPE_DIRECT, "", "", 0);
+ con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ req = HttpOpenRequestA(con, "POST", "/post/post_action.php", "HTTP/1.0", "", types, INTERNET_FLAG_FORMS_SUBMIT, 0);
ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
buffer[0] = 0;
size = sizeof(buffer);
SetLastError(0xdeadbeef);
- ret = HttpQueryInfo(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ret = HttpQueryInfoA(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
error = GetLastError();
ok(!ret || broken(ret), "HttpQueryInfo succeeded\n");
if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", error);
case INTERNET_STATUS_HANDLE_CLOSING: {
DWORD type = INTERNET_HANDLE_TYPE_CONNECT_HTTP, size = sizeof(type);
- if (InternetQueryOption(handle, INTERNET_OPTION_HANDLE_TYPE, &type, &size))
+ if (InternetQueryOptionA(handle, INTERNET_OPTION_HANDLE_TYPE, &type, &size))
ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
SetEvent(ctx->event);
break;
* other versions never do. They also hang of following tests. We disable it for everything older
* than IE7.
*/
- if(!pInternetGetSecurityInfoByURLA) {
- win_skip("Skipping async open on too old wininet version.\n");
+ if(!is_ie7plus)
return;
- }
ctx.req = NULL;
- ctx.event = CreateEvent(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
+ ctx.event = CreateEventA(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
- ses = InternetOpen("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC);
+ ses = InternetOpenA("AdvancedInstaller", 0, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(ses != NULL, "InternetOpen failed\n");
SetLastError(0xdeadbeef);
pInternetSetStatusCallbackW(ses, cb);
ResetEvent(ctx.event);
- req = InternetOpenUrl(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
+ req = InternetOpenUrlA(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
ok(!req && GetLastError() == ERROR_IO_PENDING, "InternetOpenUrl failed\n");
WaitForSingleObject(ctx.event, INFINITE);
type = 0;
size = sizeof(type);
- ret = InternetQueryOption(ctx.req, INTERNET_OPTION_HANDLE_TYPE, &type, &size);
+ ret = InternetQueryOptionA(ctx.req, INTERNET_OPTION_HANDLE_TYPE, &type, &size);
ok(ret, "InternetQueryOption failed: %u\n", GetLastError());
ok(type == INTERNET_HANDLE_TYPE_HTTP_REQUEST,
"expected INTERNET_HANDLE_TYPE_HTTP_REQUEST, got %u\n", type);
size = 0;
- ret = HttpQueryInfo(ctx.req, HTTP_QUERY_RAW_HEADERS_CRLF, NULL, &size, NULL);
+ ret = HttpQueryInfoA(ctx.req, HTTP_QUERY_RAW_HEADERS_CRLF, NULL, &size, NULL);
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "HttpQueryInfo failed\n");
ok(size > 0, "expected size > 0\n");
{
enum api function; /* api responsible for notification */
unsigned int status; /* status received */
- int async; /* delivered from another thread? */
- int todo;
- int optional;
+ BOOL async; /* delivered from another thread? */
+ BOOL todo;
+ BOOL optional;
};
struct info
static const struct notification async_send_request_ex_test[] =
{
- { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1 },
- { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, 1 },
- { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, 1 },
- { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, 1 },
- { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { internet_writefile, INTERNET_STATUS_SENDING_REQUEST, 0 },
- { internet_writefile, INTERNET_STATUS_REQUEST_SENT, 0 },
- { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, 1 },
- { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, 1 },
- { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, }
+ { internet_connect, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_open_request, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { internet_writefile, INTERNET_STATUS_SENDING_REQUEST, FALSE },
+ { internet_writefile, INTERNET_STATUS_REQUEST_SENT, FALSE },
+ { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, TRUE },
+ { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, TRUE },
+ { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, }
};
static const struct notification async_send_request_ex_test2[] =
{
- { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1, 1 },
- { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, 1, 1 },
- { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, 1 },
- { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, 1 },
- { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, 1 },
- { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, 1 },
- { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, }
+ { internet_connect, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_open_request, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, TRUE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, TRUE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, TRUE },
+ { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, TRUE },
+ { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, }
};
static const struct notification async_send_request_ex_resolve_failure_test[] =
{
- { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 },
- { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1 },
- { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 },
- { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, 1 },
- { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0, 1 },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, },
- { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, }
+ { internet_connect, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_open_request, INTERNET_STATUS_HANDLE_CREATED, FALSE },
+ { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, FALSE, FALSE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, FALSE, }
+};
+
+static const struct notification async_send_request_ex_chunked_test[] =
+{
+ { internet_connect, INTERNET_STATUS_HANDLE_CREATED },
+ { http_open_request, INTERNET_STATUS_HANDLE_CREATED },
+ { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, TRUE, FALSE, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, TRUE },
+ { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, TRUE },
+ { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, TRUE },
+ { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, TRUE },
+ { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION },
+ { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING },
+ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING }
};
static const struct notification_data notification_data[] = {
+ {
+ async_send_request_ex_chunked_test,
+ sizeof(async_send_request_ex_chunked_test)/sizeof(async_send_request_ex_chunked_test[0]),
+ "GET",
+ "test.winehq.org",
+ "tests/data.php"
+ },
{
async_send_request_ex_test,
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,
info.test = nd->test;
info.count = nd->count;
info.index = 0;
- info.wait = CreateEvent( NULL, FALSE, FALSE, NULL );
+ info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
info.thread = GetCurrentThreadId();
info.is_aborted = FALSE;
- ses = InternetOpen( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
+ ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
ok( ses != NULL, "InternetOpen failed\n" );
pInternetSetStatusCallbackA( ses, check_notification );
setup_test( &info, internet_connect, __LINE__, ERROR_SUCCESS );
- con = InternetConnect( ses, nd->host, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info );
+ con = InternetConnectA( ses, nd->host, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info );
ok( con != NULL, "InternetConnect failed %u\n", GetLastError() );
WaitForSingleObject( info.wait, 10000 );
setup_test( &info, http_open_request, __LINE__, ERROR_SUCCESS );
- req = HttpOpenRequest( con, nd->method, nd->path, NULL, NULL, accept, 0, (DWORD_PTR)&info );
+ req = HttpOpenRequestA( con, nd->method, nd->path, NULL, NULL, accept, 0, (DWORD_PTR)&info );
ok( req != NULL, "HttpOpenRequest failed %u\n", GetLastError() );
WaitForSingleObject( info.wait, 10000 );
WaitForSingleObject( info.wait, 10000 );
Sleep(100);
CloseHandle( info.wait );
+ DeleteCriticalSection( ¬ification_cs );
}
static HINTERNET closetest_session, closetest_req, closetest_conn;
static void test_connection_failure(void)
{
- HINTERNET session, connect, request;
+ test_request_t req;
DWORD error;
BOOL ret;
- session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
- ok(session != NULL, "failed to get session handle\n");
-
- connect = InternetConnectA(session, "localhost", 1, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- ok(connect != NULL, "failed to get connection handle\n");
-
- request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
- ok(request != NULL, "failed to get request handle\n");
+ open_simple_request(&req, "localhost", 1, NULL, "/");
SetLastError(0xdeadbeef);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
error = GetLastError();
ok(!ret, "unexpected success\n");
ok(error == ERROR_INTERNET_CANNOT_CONNECT, "wrong error %u\n", error);
- InternetCloseHandle(request);
- InternetCloseHandle(connect);
- InternetCloseHandle(session);
+ close_request(&req);
}
static void test_default_service_port(void)
{
HINTERNET session, connect, request;
- DWORD error;
+ DWORD size, error;
+ char buffer[128];
BOOL ret;
- session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ if(!is_ie7plus)
+ return;
+
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(session != NULL, "InternetOpen failed\n");
- connect = InternetConnect(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
+ connect = InternetConnectA(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(connect != NULL, "InternetConnect failed\n");
- request = HttpOpenRequest(connect, NULL, "/", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
ok(request != NULL, "HttpOpenRequest failed\n");
SetLastError(0xdeadbeef);
- ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
error = GetLastError();
ok(!ret, "HttpSendRequest succeeded\n");
ok(error == ERROR_INTERNET_SECURITY_CHANNEL_ERROR || error == ERROR_INTERNET_CANNOT_CONNECT,
"got %u\n", error);
+ size = sizeof(buffer);
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
+ ok(!strcmp(buffer, "test.winehq.org:80"), "Expected test.winehg.org:80, got '%s'\n", buffer);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+
+ connect = InternetConnectA(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
+ INTERNET_SERVICE_HTTP, INTERNET_FLAG_SECURE, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
+
+ size = sizeof(buffer);
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
+ ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got '%s'\n", buffer);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+
+ connect = InternetConnectA(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
+ INTERNET_SERVICE_HTTP, INTERNET_FLAG_SECURE, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
+
+ size = sizeof(buffer);
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
+ ok(ret, "HttpQueryInfo failed with error %u\n", GetLastError());
+ ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got '%s'\n", buffer);
+
InternetCloseHandle(request);
InternetCloseHandle(connect);
InternetCloseHandle(session);
#undef STATUS_STRING
}
+static void WINAPI header_cb( HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD len )
+{
+ BOOL ret;
+ DWORD index, size;
+ char buf[256];
+
+ if (status == INTERNET_STATUS_SENDING_REQUEST)
+ {
+ ret = HttpAddRequestHeadersA( handle, "winetest: winetest", ~0u, HTTP_ADDREQ_FLAG_ADD );
+ ok( ret, "HttpAddRequestHeadersA failed %u\n", GetLastError() );
+ SetEvent( (HANDLE)ctx );
+ }
+ else if (status == INTERNET_STATUS_REQUEST_SENT)
+ {
+ index = 0;
+ size = sizeof(buf);
+ ret = HttpQueryInfoA( handle, HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
+ buf, &size, &index );
+ ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
+ ok( strstr( buf, "winetest: winetest" ) != NULL, "header missing\n" );
+ SetEvent( (HANDLE)ctx );
+ }
+}
+
+static void test_concurrent_header_access(void)
+{
+ HINTERNET ses, con, req;
+ DWORD err;
+ BOOL ret;
+ HANDLE wait = CreateEventW( NULL, FALSE, FALSE, NULL );
+
+ ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
+ ok( ses != NULL, "InternetOpenA failed\n" );
+
+ con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
+ INTERNET_SERVICE_HTTP, 0, 0 );
+ ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
+
+ req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, (DWORD_PTR)wait );
+ ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
+
+ pInternetSetStatusCallbackA( req, header_cb );
+
+ SetLastError( 0xdeadbeef );
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ err = GetLastError();
+ ok( !ret, "HttpSendRequestA succeeded\n" );
+ ok( err == ERROR_IO_PENDING, "got %u\n", ERROR_IO_PENDING );
+
+ WaitForSingleObject( wait, 5000 );
+ WaitForSingleObject( wait, 5000 );
+
+ InternetCloseHandle( req );
+ InternetCloseHandle( con );
+ InternetCloseHandle( ses );
+ CloseHandle( wait );
+}
+
START_TEST(http)
{
HMODULE hdll;
pInternetSetStatusCallbackW = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackW");
pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA");
+ if(!pInternetGetSecurityInfoByURLA) {
+ is_ie7plus = FALSE;
+ win_skip("IE6 found. It's too old for some tests.\n");
+ }
+
init_status_tests();
test_InternetCloseHandle();
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]);
test_async_HttpSendRequestEx(¬ification_data[0]);
test_async_HttpSendRequestEx(¬ification_data[1]);
test_async_HttpSendRequestEx(¬ification_data[2]);
+ test_async_HttpSendRequestEx(¬ification_data[3]);
InternetOpenRequest_test();
test_http_cache();
+ InternetLockRequestFile_test();
InternetOpenUrlA_test();
HttpHeaders_test();
test_http_connection();
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]);
test_connection_failure();
test_default_service_port();
+ test_concurrent_header_access();
}