[1/2] wininet: Always set last error in HttpSendRequest{,Ex}.

Hans Leidekker hans at codeweavers.com
Mon Dec 21 04:13:44 CST 2009


Fixes http://bugs.winehq.org/show_bug.cgi?id=21089
---
 dlls/wininet/http.c       |    6 ++----
 dlls/wininet/tests/http.c |   13 +++++++++----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 6786380..aa5a449 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4000,8 +4000,7 @@ lend:
         WININET_Release( &lpwhr->hdr );
 
     TRACE("<---\n");
-    if(res != ERROR_SUCCESS)
-        SetLastError(res);
+    SetLastError(res);
     return res == ERROR_SUCCESS;
 }
 
@@ -4089,8 +4088,7 @@ lend:
     if( lpwhr )
         WININET_Release( &lpwhr->hdr );
 
-    if(res != ERROR_SUCCESS)
-        SetLastError(res);
+    SetLastError(res);
     return res == ERROR_SUCCESS;
 }
 
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 892bb1e..345172c 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -971,8 +971,7 @@ static void HttpSendRequestEx_test(void)
     HINTERNET hRequest;
 
     INTERNET_BUFFERS BufferIn;
-    DWORD dwBytesWritten;
-    DWORD dwBytesRead;
+    DWORD dwBytesWritten, dwBytesRead, error;
     CHAR szBuffer[256];
     int i;
     BOOL ret;
@@ -1008,8 +1007,11 @@ static void HttpSendRequestEx_test(void)
     BufferIn.dwOffsetLow = 0;
     BufferIn.dwOffsetHigh = 0;
 
+    SetLastError(0xdeadbeef);
     ret = HttpSendRequestEx(hRequest, &BufferIn, NULL, 0 ,0);
-    ok(ret, "HttpSendRequestEx Failed with error %u\n", GetLastError());
+    error = GetLastError();
+    ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
+    ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
 
     for (i = 3; szPostData[i]; i++)
         ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
@@ -1752,7 +1754,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
 static void test_basic_request(int port, const char *verb, const char *url)
 {
     HINTERNET hi, hc, hr;
-    DWORD r, count;
+    DWORD r, count, error;
     char buffer[0x100];
 
     hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
@@ -1764,8 +1766,11 @@ static void test_basic_request(int port, const char *verb, const char *url)
     hr = HttpOpenRequest(hc, verb, url, 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, "expected ERROR_SUCCESS, got %u\n", error);
 
     count = 0;
     memset(buffer, 0, sizeof buffer);
-- 
1.6.3.3





More information about the wine-patches mailing list