wininet: Added beginning support for HTTP cache files.
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 964140e..d718eea 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2283,6 +2283,20 @@
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, szHost);
+ if(!host_header)
+ return FALSE;
+
+ sprintfW(buf, formatW, host_header->lpszValue, req->lpszPath); /* FIXME */
+ return TRUE;
+}
+
/***********************************************************************
* HTTP_HandleRedirect (internal)
*/
@@ -2743,6 +2757,32 @@
}
while (loop_next);
+ /* FIXME: Better check, when we have to create the cache file */
+ if(bSuccess && (lpwhr->hdr.dwFlags & INTERNET_FLAG_NEED_FILE)) {
+ WCHAR url[INTERNET_MAX_URL_LENGTH];
+ WCHAR cacheFileName[MAX_PATH+1];
+ BOOL b;
+
+ b = HTTP_GetRequestURL(lpwhr, url);
+ if(!b) {
+ WARN("Could not get URL\n");
+ goto lend;
+ }
+
+ b = CreateUrlCacheEntryW(url, lpwhr->dwContentLength > 0 ? lpwhr->dwContentLength : 0, NULL, cacheFileName, 0);
+ if(b) {
+ lpwhr->lpszCacheFile = WININET_strdupW(cacheFileName);
+ lpwhr->hCacheFile = CreateFileW(lpwhr->lpszCacheFile, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if(lpwhr->hCacheFile == INVALID_HANDLE_VALUE) {
+ WARN("Could not create file: %u\n", GetLastError());
+ lpwhr->hCacheFile = NULL;
+ }
+ }else {
+ WARN("Could not create cache entry: %08x\n", GetLastError());
+ }
+ }
+
lend:
HeapFree(GetProcessHeap(), 0, requestString);
@@ -3393,6 +3433,14 @@
TRACE("\n");
+ if(lpwhr->hCacheFile)
+ CloseHandle(lpwhr->hCacheFile);
+
+ if(lpwhr->lpszCacheFile) {
+ DeleteFileW(lpwhr->lpszCacheFile); /* FIXME */
+ HeapFree(GetProcessHeap(), 0, lpwhr->lpszCacheFile);
+ }
+
WININET_Release(&lpwhr->lpHttpSession->hdr);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);