summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrace Kloba <>2009-04-02 10:55:37 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-02 10:55:37 -0700
commit3afdd56470d6d4dcb20fe0f68ec9e54a167a9d74 (patch)
tree4e2f90a93de62ac96e360536c807348ceaf3d11d
parent238ddbb8a2961e6919d802694ef9ce7743cff61c (diff)
downloadframeworks_base-3afdd56470d6d4dcb20fe0f68ec9e54a167a9d74.zip
frameworks_base-3afdd56470d6d4dcb20fe0f68ec9e54a167a9d74.tar.gz
frameworks_base-3afdd56470d6d4dcb20fe0f68ec9e54a167a9d74.tar.bz2
AI 144242: Fix 1750062. When createCacheFile, if we get 303, or redirect with cookies, or "no-store", make sure to remove the existing entry in the cache db before returning null for CachedResult.
BUG=1750062 Automated import of CL 144242
-rw-r--r--core/java/android/webkit/CacheManager.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java
index c761602..65a017d 100644
--- a/core/java/android/webkit/CacheManager.java
+++ b/core/java/android/webkit/CacheManager.java
@@ -340,7 +340,7 @@ public final class CacheManager {
* @hide - hide createCacheFile since it has a parameter of type headers, which is
* in a hidden package.
*/
- // can be called from any thread
+ // only called from WebCore thread
public static CacheResult createCacheFile(String url, int statusCode,
Headers headers, String mimeType, boolean forceCache) {
if (!forceCache && mDisabled) {
@@ -349,17 +349,25 @@ public final class CacheManager {
// according to the rfc 2616, the 303 response MUST NOT be cached.
if (statusCode == 303) {
+ // remove the saved cache if there is any
+ mDataBase.removeCache(url);
return null;
}
// like the other browsers, do not cache redirects containing a cookie
// header.
if (checkCacheRedirect(statusCode) && !headers.getSetCookie().isEmpty()) {
+ // remove the saved cache if there is any
+ mDataBase.removeCache(url);
return null;
}
CacheResult ret = parseHeaders(statusCode, headers, mimeType);
- if (ret != null) {
+ if (ret == null) {
+ // this should only happen if the headers has "no-store" in the
+ // cache-control. remove the saved cache if there is any
+ mDataBase.removeCache(url);
+ } else {
setupFiles(url, ret);
try {
ret.outStream = new FileOutputStream(ret.outFile);