[2/2] wininet: Fix setting proxy user and password per InternetSetOption

André Hentschel nerv at dawncrow.de
Tue Aug 23 14:02:01 CDT 2011


---
 dlls/wininet/internet.c   |   26 ++++++++++++++++++++++++--
 dlls/wininet/tests/http.c |    4 ----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 79ec790..b4375bf 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -2639,6 +2639,26 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
         }
         break;
     }
+    case INTERNET_OPTION_PROXY_USERNAME:
+    case INTERNET_OPTION_PROXY_PASSWORD:
+    {
+        http_request_t *request = (http_request_t*)lpwhh;
+        if (!lpwhh)
+        {
+            SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+            return FALSE;
+        }
+        if (!lpBuffer || !dwBufferLength)
+        {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
+        if (dwOption == INTERNET_OPTION_PROXY_USERNAME)
+            request->session->appInfo->proxyUsername = heap_strdupW(lpBuffer);
+        else
+            request->session->appInfo->proxyPassword = heap_strdupW(lpBuffer);
+        break;
+    }
     case INTERNET_OPTION_CODEPAGE:
       {
         ULONG codepage = *(ULONG *)lpBuffer;
@@ -2880,10 +2900,12 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
     case INTERNET_OPTION_USER_AGENT:
     case INTERNET_OPTION_USERNAME:
     case INTERNET_OPTION_PASSWORD:
-        wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
+    case INTERNET_OPTION_PROXY_USERNAME:
+    case INTERNET_OPTION_PROXY_PASSWORD:
+        wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength + 1,
                                    NULL, 0 );
         wbuffer = heap_alloc(wlen*sizeof(WCHAR) );
-        MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
+        MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength + 1,
                                    wbuffer, wlen );
         break;
     case INTERNET_OPTION_PER_CONNECTION_OPTION: {
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index f3e85cb..4ee5572 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1941,22 +1941,18 @@ static void test_proxy_direct(int port)
 
 
     /* set the user + password then try again */
-    todo_wine {
     r = InternetSetOption(hr, INTERNET_OPTION_PROXY_USERNAME, username, 4);
     ok(r, "failed to set user\n");
 
     r = InternetSetOption(hr, INTERNET_OPTION_PROXY_PASSWORD, password, 4);
     ok(r, "failed to set password\n");
-    }
 
     r = HttpSendRequest(hr, NULL, 0, NULL, 0);
     ok(r, "HttpSendRequest failed\n");
     sz = sizeof buffer;
     r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE, buffer, &sz, NULL);
     ok(r, "HttpQueryInfo failed\n");
-    todo_wine {
     ok(!strcmp(buffer, "200"), "proxy code wrong\n");
-    }
 
 
     InternetCloseHandle(hr);
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list