http: Test for HttpSendRequestEx
Aric Stewart
aric at codeweavers.com
Fri Nov 18 15:58:39 CST 2005
Test for HttpSendRequestEx, hits a webpage set up by Newman at
crossover.codeweavers.com.
-------------- next part --------------
Index: dlls/wininet/tests/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/tests/http.c,v
retrieving revision 1.31
diff -u -r1.31 http.c
--- dlls/wininet/tests/http.c 16 Nov 2005 11:21:41 -0000 1.31
+++ dlls/wininet/tests/http.c 18 Nov 2005 21:57:34 -0000
@@ -1040,6 +1040,65 @@
HeapFree(GetProcessHeap(), 0, szUrl);
}
+static void HttpSendRequestEx_test()
+{
+ HINTERNET hSession;
+ HINTERNET hConnect;
+ HINTERNET hRequest;
+
+ INTERNET_BUFFERS BufferIn;
+ DWORD dwBytesWritten;
+ DWORD dwBytesRead;
+ CHAR szBuffer[256];
+ int i;
+
+ static const char szPostData[] = "mode=Test";
+ static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
+
+ hSession = InternetOpen("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",
+ 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",
+ NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok( hRequest != NULL, "Failed to open request handle\n");
+
+
+ BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS);
+ BufferIn.Next = NULL;
+ BufferIn.lpcszHeader = szContentType;
+ BufferIn.dwHeadersLength = sizeof(szContentType);
+ BufferIn.dwHeadersTotal = sizeof(szContentType);
+ BufferIn.lpvBuffer = NULL;
+ BufferIn.dwBufferLength = 0;
+ BufferIn.dwBufferTotal = sizeof(szPostData)-1;
+ BufferIn.dwOffsetLow = 0;
+ BufferIn.dwOffsetHigh = 0;
+
+ ok(HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0),
+ "SendRequestEx Failed\n");
+
+ for (i = 0; szPostData[i]; i++)
+ ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
+ "InternetWriteFile failed\n");
+
+ ok(HttpEndRequest(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
+
+ ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
+ "Unable to read responce\n");
+ szBuffer[dwBytesRead] = 0;
+
+ ok(dwBytesRead == 13,"Read %i bytes instead of 13\n",dwBytesRead);
+ ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0,"Got string %s\n",szBuffer);
+
+ ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
+ ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
+ ok(InternetCloseHandle(hSession), "Close session handle failed\n");
+}
+
START_TEST(http)
{
InternetReadFile_test(INTERNET_FLAG_ASYNC);
@@ -1053,4 +1112,5 @@
InternetTimeToSystemTimeA_test();
InternetTimeToSystemTimeW_test();
InternetCreateUrlA_test();
+ HttpSendRequestEx_test();
}
More information about the wine-patches
mailing list