[2/2] wininet: Implement InternetQueryOption(INTERNET_OPTION_CACHE_TIMESTAMPS).

Hans Leidekker hans at codeweavers.com
Tue Jun 16 08:13:52 CDT 2009


diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8f9f404..cb79308 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1568,6 +1568,20 @@ static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr)
                           INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
 }
 
+static BOOL HTTP_GetRequestURL(WININETHTTPREQW *req, LPWSTR buf)
+{
+    LPHTTPHEADERW host_header;
+
+    static const WCHAR formatW[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
+
+    host_header = HTTP_GetHeader(req, hostW);
+    if(!host_header)
+        return FALSE;
+
+    sprintfW(buf, formatW, host_header->lpszValue, req->lpszPath); /* FIXME */
+    return TRUE;
+}
+
 static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 {
     WININETHTTPREQW *req = (WININETHTTPREQW*)hdr;
@@ -1620,6 +1634,41 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
         }
     }
 
+    case INTERNET_OPTION_CACHE_TIMESTAMPS: {
+        INTERNET_CACHE_ENTRY_INFOW *info;
+        INTERNET_CACHE_TIMESTAMPS *ts = buffer;
+        WCHAR url[INTERNET_MAX_URL_LENGTH];
+        DWORD nbytes, error;
+        BOOL ret;
+
+        TRACE("INTERNET_OPTION_CACHE_TIMESTAMPS\n");
+
+        if (*size < sizeof(*ts))
+        {
+            *size = sizeof(*ts);
+            return ERROR_INSUFFICIENT_BUFFER;
+        }
+        nbytes = 0;
+        HTTP_GetRequestURL(req, url);
+        ret = GetUrlCacheEntryInfoW(url, NULL, &nbytes);
+        error = GetLastError();
+        if (!ret && error == ERROR_INSUFFICIENT_BUFFER)
+        {
+            if (!(info = HeapAlloc(GetProcessHeap(), 0, nbytes)))
+                return ERROR_OUTOFMEMORY;
+
+            GetUrlCacheEntryInfoW(url, info, &nbytes);
+
+            ts->ftExpires = info->ExpireTime;
+            ts->ftLastModified = info->LastModifiedTime;
+
+            HeapFree(GetProcessHeap(), 0, info);
+            *size = sizeof(*ts);
+            return ERROR_SUCCESS;
+        }
+        return error;
+    }
+
     case INTERNET_OPTION_DATAFILE_NAME: {
         DWORD req_size;
 
@@ -3244,20 +3293,6 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
     return result;
 }
 
-static BOOL HTTP_GetRequestURL(WININETHTTPREQW *req, LPWSTR buf)
-{
-    LPHTTPHEADERW host_header;
-
-    static const WCHAR formatW[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
-
-    host_header = HTTP_GetHeader(req, hostW);
-    if(!host_header)
-        return FALSE;
-
-    sprintfW(buf, formatW, host_header->lpszValue, req->lpszPath); /* FIXME */
-    return TRUE;
-}
-
 /***********************************************************************
  *           HTTP_GetRedirectURL (internal)
  */
diff --git a/include/wininet.h b/include/wininet.h
index e37700a..fb6f31f 100644
--- a/include/wininet.h
+++ b/include/wininet.h
@@ -1536,6 +1536,12 @@ typedef struct _INTERNET_CACHE_ENTRY_INFOW {
 DECL_WINELIB_TYPE_AW(INTERNET_CACHE_ENTRY_INFO)
 DECL_WINELIB_TYPE_AW(LPINTERNET_CACHE_ENTRY_INFO)
 
+typedef struct _INTERNET_CACHE_TIMESTAMPS
+{
+    FILETIME ftExpires;
+    FILETIME ftLastModified;
+} INTERNET_CACHE_TIMESTAMPS, *LPINTERNET_CACHE_TIMESTAMPS;
+
 BOOLAPI CreateUrlCacheEntryA(LPCSTR ,DWORD ,LPCSTR ,LPSTR ,DWORD);
 BOOLAPI CreateUrlCacheEntryW(LPCWSTR ,DWORD ,LPCWSTR ,LPWSTR ,DWORD);
 #define CreateUrlCacheEntry  WINELIB_NAME_AW(CreateUrlCacheEntry)



More information about the wine-patches mailing list