[WININET]
authorChristoph von Wittich <christoph_vw@reactos.org>
Sat, 29 May 2010 13:41:35 +0000 (13:41 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sat, 29 May 2010 13:41:35 +0000 (13:41 +0000)
-sync to wine 1.2 RC2
-enable http compression with zlib

svn path=/trunk/; revision=47412

reactos/dll/win32/wininet/ftp.c
reactos/dll/win32/wininet/http.c
reactos/dll/win32/wininet/internet.c
reactos/dll/win32/wininet/internet.h
reactos/dll/win32/wininet/netconnection.c
reactos/dll/win32/wininet/urlcache.c
reactos/dll/win32/wininet/utility.c
reactos/dll/win32/wininet/wininet.rbuild
reactos/dll/win32/wininet/wininet_Si.rc
reactos/include/psdk/wininet.h
reactos/include/reactos/wine/config.h

index 1f03199..80cc6f0 100644 (file)
@@ -1176,7 +1176,7 @@ static DWORD FTPFILE_QueryOption(object_header_t *hdr, DWORD option, void *buffe
         }
     }
     }
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read)
@@ -2395,7 +2395,7 @@ static DWORD FTPSESSION_QueryOption(object_header_t *hdr, DWORD option, void *bu
         return ERROR_SUCCESS;
     }
 
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static const object_vtbl_t FTPSESSIONVtbl = {
@@ -3476,7 +3476,7 @@ static DWORD FTPFINDNEXT_QueryOption(object_header_t *hdr, DWORD option, void *b
         return ERROR_SUCCESS;
     }
 
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static DWORD FTPFINDNEXT_FindNextFileW(object_header_t *hdr, void *data)
index 57b7372..d14a522 100644 (file)
@@ -1756,7 +1756,7 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe
     }
     }
 
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer, DWORD size)
@@ -3464,6 +3464,10 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *lpwhr, LPCWSTR lpszHeaders,
          * for all the data */
         HTTP_DrainContent(lpwhr);
         lpwhr->dwContentRead = 0;
+        if(redirected) {
+            lpwhr->dwContentLength = ~0u;
+            lpwhr->dwBytesToWrite = 0;
+        }
 
         if (TRACE_ON(wininet))
         {
@@ -3670,7 +3674,7 @@ lend:
             HTTP_ReceiveRequestData(lpwhr, TRUE);
         else
         {
-            iar.dwResult = (DWORD_PTR)lpwhr->hdr.hInternet;
+            iar.dwResult = 0;
             iar.dwError = res;
 
             INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
@@ -4164,7 +4168,7 @@ static DWORD HTTPSESSION_QueryOption(object_header_t *hdr, DWORD option, void *b
         return ERROR_SUCCESS;
     }
 
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static DWORD HTTPSESSION_SetOption(object_header_t *hdr, DWORD option, void *buffer, DWORD size)
@@ -4261,11 +4265,8 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
         if(hIC->lpszProxyBypass)
             FIXME("Proxy bypass is ignored.\n");
     }
-    if (lpszServerName && lpszServerName[0])
-    {
-        lpwhs->lpszServerName = heap_strdupW(lpszServerName);
-        lpwhs->lpszHostName = heap_strdupW(lpszServerName);
-    }
+    lpwhs->lpszServerName = heap_strdupW(lpszServerName);
+    lpwhs->lpszHostName = heap_strdupW(lpszServerName);
     if (lpszUserName && lpszUserName[0])
         lpwhs->lpszUserName = heap_strdupW(lpszUserName);
     if (lpszPassword && lpszPassword[0])
@@ -4362,6 +4363,10 @@ static DWORD HTTP_OpenConnection(http_request_t *lpwhr)
     if(res != ERROR_SUCCESS)
        goto lend;
 
+    INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
+            INTERNET_STATUS_CONNECTED_TO_SERVER,
+            szaddr, strlen(szaddr)+1);
+
     if (lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE)
     {
         /* Note: we differ from Microsoft's WinINet here. they seem to have
@@ -4370,20 +4375,31 @@ static DWORD HTTP_OpenConnection(http_request_t *lpwhr)
          * behaviour to be more correct and to not cause any incompatibilities
          * because using a secure connection through a proxy server is a rare
          * case that would be hard for anyone to depend on */
-        if (hIC->lpszProxy && (res = HTTP_SecureProxyConnect(lpwhr)) != ERROR_SUCCESS)
+        if (hIC->lpszProxy && (res = HTTP_SecureProxyConnect(lpwhr)) != ERROR_SUCCESS) {
+            HTTPREQ_CloseConnection(&lpwhr->hdr);
             goto lend;
+        }
 
         res = NETCON_secure_connect(&lpwhr->netConnection, lpwhs->lpszHostName);
         if(res != ERROR_SUCCESS)
         {
             WARN("Couldn't connect securely to host\n");
+
+            if((lpwhr->hdr.ErrorMask&INTERNET_ERROR_MASK_COMBINED_SEC_CERT) && (
+                    res == ERROR_INTERNET_SEC_CERT_DATE_INVALID
+                    || res == ERROR_INTERNET_INVALID_CA
+                    || res == ERROR_INTERNET_SEC_CERT_NO_REV
+                    || res == ERROR_INTERNET_SEC_CERT_REV_FAILED
+                    || res == ERROR_INTERNET_SEC_CERT_REVOKED
+                    || res == ERROR_INTERNET_SEC_INVALID_CERT
+                    || res == ERROR_INTERNET_SEC_CERT_CN_INVALID))
+                res = ERROR_INTERNET_SEC_CERT_ERRORS;
+
+            HTTPREQ_CloseConnection(&lpwhr->hdr);
             goto lend;
         }
     }
 
-    INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
-                          INTERNET_STATUS_CONNECTED_TO_SERVER,
-                          szaddr, strlen(szaddr)+1);
 
 lend:
     lpwhr->read_pos = lpwhr->read_size = 0;
index 6fc8a21..0017360 100644 (file)
@@ -812,7 +812,7 @@ static DWORD APPINFO_QueryOption(object_header_t *hdr, DWORD option, void *buffe
         }
     }
 
-    return INET_QueryOption(option, buffer, size, unicode);
+    return INET_QueryOption(hdr, option, buffer, size, unicode);
 }
 
 static const object_vtbl_t APPINFOVtbl = {
@@ -1447,7 +1447,7 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
     lpUrlComponents->nScheme = UCW.nScheme;
     lpUrlComponents->nPort = UCW.nPort;
 
-    TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
+    TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_a(lpszUrl),
           debugstr_an(lpUrlComponents->lpszScheme, lpUrlComponents->dwSchemeLength),
           debugstr_an(lpUrlComponents->lpszHostName, lpUrlComponents->dwHostNameLength),
           debugstr_an(lpUrlComponents->lpszUrlPath, lpUrlComponents->dwUrlPathLength),
@@ -1860,7 +1860,7 @@ BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
     DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
 
     TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer,
-        lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags);
+        lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
 
     if(dwFlags & ICU_DECODE)
     {
@@ -2194,7 +2194,7 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
     return res == ERROR_SUCCESS;
 }
 
-DWORD INET_QueryOption(DWORD option, void *buffer, DWORD *size, BOOL unicode)
+DWORD INET_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 {
     static BOOL warn = TRUE;
 
@@ -2357,6 +2357,25 @@ DWORD INET_QueryOption(DWORD option, void *buffer, DWORD *size, BOOL unicode)
         return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
     case INTERNET_OPTION_POLICY:
         return ERROR_INVALID_PARAMETER;
+    case INTERNET_OPTION_CONTEXT_VALUE:
+    {
+        if (!hdr)
+            return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
+        if (!size)
+            return ERROR_INVALID_PARAMETER;
+
+        if (*size < sizeof(DWORD_PTR))
+        {
+            *size = sizeof(DWORD_PTR);
+            return ERROR_INSUFFICIENT_BUFFER;
+        }
+        if (!buffer)
+            return ERROR_INVALID_PARAMETER;
+
+        *(DWORD_PTR *)buffer = hdr->dwContext;
+        *size = sizeof(DWORD_PTR);
+        return ERROR_SUCCESS;
+    }
     }
 
     FIXME("Stub for %d\n", option);
@@ -2388,7 +2407,7 @@ BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
             WININET_Release(hdr);
         }
     }else {
-        res = INET_QueryOption(dwOption, lpBuffer, lpdwBufferLength, TRUE);
+        res = INET_QueryOption(NULL, dwOption, lpBuffer, lpdwBufferLength, TRUE);
     }
 
     if(res != ERROR_SUCCESS)
@@ -2421,7 +2440,7 @@ BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
             WININET_Release(hdr);
         }
     }else {
-        res = INET_QueryOption(dwOption, lpBuffer, lpdwBufferLength, FALSE);
+        res = INET_QueryOption(NULL, dwOption, lpBuffer, lpdwBufferLength, FALSE);
     }
 
     if(res != ERROR_SUCCESS)
@@ -2484,8 +2503,19 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
       break;
     case INTERNET_OPTION_ERROR_MASK:
       {
-        ULONG flags = *(ULONG *)lpBuffer;
-        FIXME("Option INTERNET_OPTION_ERROR_MASK(%d): STUB\n", flags);
+        if(!lpwhh) {
+            SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+            return FALSE;
+        } else if(*(ULONG*)lpBuffer & (~(INTERNET_ERROR_MASK_INSERT_CDROM|
+                        INTERNET_ERROR_MASK_COMBINED_SEC_CERT|
+                        INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY))) {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            ret = FALSE;
+        } else if(dwBufferLength != sizeof(ULONG)) {
+            SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH);
+            ret = FALSE;
+        } else
+            lpwhh->ErrorMask = *(ULONG*)lpBuffer;
       }
       break;
     case INTERNET_OPTION_CODEPAGE:
@@ -2550,8 +2580,21 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
         break;
     }
     case INTERNET_OPTION_CONTEXT_VALUE:
-        FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
-        break;
+    {
+        if (!lpwhh)
+        {
+            SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+            return FALSE;
+        }
+        if (!lpBuffer || dwBufferLength != sizeof(DWORD_PTR))
+        {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            ret = FALSE;
+        }
+        else
+            lpwhh->dwContext = *(DWORD_PTR *)lpBuffer;
+        break;
+    }
     case INTERNET_OPTION_SECURITY_FLAGS:
         FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
         break;
index 8fcc0cf..a531ccd 100644 (file)
@@ -160,6 +160,7 @@ struct _object_header_t
     DWORD  dwFlags;
     DWORD_PTR dwContext;
     DWORD  dwError;
+    ULONG  ErrorMask;
     DWORD  dwInternalFlags;
     LONG   refs;
     INTERNET_STATUS_CALLBACK lpfnStatusCB;
@@ -392,7 +393,7 @@ object_header_t *WININET_AddRef( object_header_t *info );
 BOOL WININET_Release( object_header_t *info );
 BOOL WININET_FreeHandle( HINTERNET hinternet );
 
-DWORD INET_QueryOption(DWORD,void*,DWORD*,BOOL);
+DWORD INET_QueryOption( object_header_t *, DWORD, void *, DWORD *, BOOL );
 
 time_t ConvertTimeString(LPCWSTR asctime);
 
index c2560b5..5aa647a 100644 (file)
@@ -134,6 +134,7 @@ MAKE_FUNCPTR(SSL_shutdown);
 MAKE_FUNCPTR(SSL_write);
 MAKE_FUNCPTR(SSL_read);
 MAKE_FUNCPTR(SSL_pending);
+MAKE_FUNCPTR(SSL_get_error);
 MAKE_FUNCPTR(SSL_get_ex_new_index);
 MAKE_FUNCPTR(SSL_get_ex_data);
 MAKE_FUNCPTR(SSL_set_ex_data);
@@ -330,7 +331,9 @@ static int netconn_secure_verify(int preverify_ok, X509_STORE_CTX *ctx)
             CertFreeCertificateContext(endCert);
             CertCloseStore(store, 0);
         }
-    }
+    } else
+        pSSL_set_ex_data(ssl, error_idx, (void *)ERROR_INTERNET_SEC_CERT_ERRORS);
+
     return ret;
 }
 
@@ -392,6 +395,7 @@ DWORD NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
        DYNSSL(SSL_write);
        DYNSSL(SSL_read);
        DYNSSL(SSL_pending);
+        DYNSSL(SSL_get_error);
        DYNSSL(SSL_get_ex_new_index);
        DYNSSL(SSL_get_ex_data);
        DYNSSL(SSL_set_ex_data);
@@ -772,6 +776,12 @@ DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int
     {
 #ifdef SONAME_LIBSSL
        *recvd = pSSL_read(connection->ssl_s, buf, len);
+
+        /* Check if EOF was received */
+        if(!*recvd && (pSSL_get_error(connection->ssl_s, *recvd)==SSL_ERROR_ZERO_RETURN
+                    || pSSL_get_error(connection->ssl_s, *recvd)==SSL_ERROR_SYSCALL))
+            return ERROR_SUCCESS;
+
         return *recvd > 0 ? ERROR_SUCCESS : ERROR_INTERNET_CONNECTION_ABORTED;
 #else
        return ERROR_NOT_SUPPORTED;
index 6a39c69..c617a93 100644 (file)
@@ -2435,7 +2435,6 @@ static BOOL CommitUrlCacheEntryInternal(
     DWORD dwFileSizeLow = 0;
     DWORD dwFileSizeHigh = 0;
     BYTE cDirectory = 0;
-    int len;
     char achFile[MAX_PATH];
     LPSTR lpszUrlNameA = NULL;
     LPSTR lpszFileExtensionA = NULL;
@@ -2556,7 +2555,6 @@ static BOOL CommitUrlCacheEntryInternal(
     dwBytesNeeded = DWORD_ALIGN(dwBytesNeeded + strlen(lpszUrlNameA) + 1);
     if (lpszLocalFileName)
     {
-        len = WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, NULL, 0, NULL, NULL);
         dwOffsetLocalFileName = dwBytesNeeded;
         dwBytesNeeded = DWORD_ALIGN(dwBytesNeeded + strlen(pchLocalFileName) + 1);
     }
index 66fbecd..0639f40 100644 (file)
@@ -307,6 +307,7 @@ VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
         case INTERNET_STATUS_CONNECTING_TO_SERVER:
         case INTERNET_STATUS_CONNECTED_TO_SERVER:
             lpvNewInfo = heap_strdupAtoW(lpvStatusInfo);
+            dwStatusInfoLength *= sizeof(WCHAR);
             break;
         case INTERNET_STATUS_RESOLVING_NAME:
         case INTERNET_STATUS_REDIRECT:
@@ -325,6 +326,7 @@ VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
         case INTERNET_STATUS_RESOLVING_NAME:
         case INTERNET_STATUS_REDIRECT:
             lpvNewInfo = heap_strdupWtoA(lpvStatusInfo);
+            dwStatusInfoLength /= sizeof(WCHAR);
             break;
         }
     }
index 45b87b1..ac2c43f 100644 (file)
@@ -6,6 +6,7 @@
        <importlibrary definition="wininet.spec" />
        <include base="wininet">.</include>
        <include base="ReactOS">include/reactos/wine</include>
+       <include base="zlib">.</include>
        <define name="__WINESRC__" />
        <define name="_WINE" />
 
@@ -22,6 +23,7 @@
        <library>secur32</library>
        <library>crypt32</library>
        <library>ws2_32</library>
+       <library>zlib</library>
        <library>pseh</library>
        <file>cookie.c</file>
        <file>dialogs.c</file>
index b5bf291..488104e 100644 (file)
@@ -27,11 +27,11 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Vnos omrežnega gesla"
 FONT 8, "MS Shell Dlg"
 {
- LTEXT "Vnesite uporabniško ime in geslo:", -1, 40, 6, 150, 15
- LTEXT "Proksi", -1, 40, 26, 50, 10
- LTEXT "Kraljestvo", -1, 40, 46, 50, 10
- LTEXT "Uporabniško ime", -1, 40, 66, 50, 10
- LTEXT "Geslo", -1, 40, 86, 50, 10
+ LTEXT "Vnesite uporabniško ime in geslo:", -1, 20, 6, 150, 15
+ LTEXT "Proksi", -1, 20, 26, 50, 10
+ LTEXT "Področje", -1, 20, 46, 50, 10
+ LTEXT "Uporabniško ime", -1, 20, 66, 55, 10
+ LTEXT "Geslo", -1, 20, 86, 50, 10
  LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0
  LTEXT "" IDC_REALM, 80, 46, 150, 14, 0
  EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
@@ -42,6 +42,26 @@ FONT 8, "MS Shell Dlg"
  PUSHBUTTON "Prekliči", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
 }
 
+IDD_AUTHDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Authentication Required"
+FONT 8, "MS Shell Dlg"
+{
+ LTEXT "Vnesite uporabniško ime in geslo:", -1, 20, 6, 150, 15
+ LTEXT "Server", -1, 20, 26, 50, 10
+ LTEXT "Področje", -1, 20, 46, 50, 10
+ LTEXT "Uporabniško ime", -1, 20, 66, 55, 10
+ LTEXT "Geslo", -1, 20, 86, 50, 10
+ LTEXT "" IDC_SERVER, 80, 26, 150, 14, 0
+ LTEXT "" IDC_REALM, 80, 46, 150, 14, 0
+ EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
+ EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD
+ CHECKBOX "&Shrani geslo (nezaščiteno)", IDC_SAVEPASSWORD,
+           80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "V redu", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON
+ PUSHBUTTON "Prekliči", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
 STRINGTABLE DISCARDABLE
 {
   IDS_LANCONNECTION "LAN povezava"
index 1cb0508..a0ec408 100644 (file)
@@ -122,6 +122,9 @@ INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP)
                                 )
 
 #define INTERNET_ERROR_MASK_INSERT_CDROM                    0x1
+#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT               0x2
+#define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG               0x4
+#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8
 
 #define INTERNET_OPTIONS_MASK   (~INTERNET_FLAGS_MASK)
 #define WININET_API_FLAG_ASYNC          0x00000001
index 406b5fb..404783b 100644 (file)
 /* Define to 1 if you have the <openssl/ssl.h> header file. */
 /* #undef HAVE_OPENSSL_SSL_H */
 
+/* Define to 1 if you have the `z' library (-lz). */
+#define HAVE_ZLIB 1
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#define HAVE_ZLIB_H 1
+
 /* Define to 1 if you have the `pclose' function. */
 #define HAVE_PCLOSE 1