diff options
author | Grace Kloba <klobag@google.com> | 2009-06-29 14:49:10 -0700 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2009-06-29 14:49:10 -0700 |
commit | 0b956e1353a691674cb22c899c5a444b92532b60 (patch) | |
tree | 68af6c6a8ffe7e7bcd2733b791abc3365dfe96bf /core/java/android/webkit | |
parent | 5f9c2ab7a7af192876c690323b84cc099113c2c7 (diff) | |
download | frameworks_base-0b956e1353a691674cb22c899c5a444b92532b60.zip frameworks_base-0b956e1353a691674cb22c899c5a444b92532b60.tar.gz frameworks_base-0b956e1353a691674cb22c899c5a444b92532b60.tar.bz2 |
Add content-disposition into the cache header as it is needed by Flash.
As WebKit is using string version of "expires", pass it with the rest of the headers.
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r-- | core/java/android/webkit/CacheLoader.java | 16 | ||||
-rw-r--r-- | core/java/android/webkit/CacheManager.java | 13 | ||||
-rw-r--r-- | core/java/android/webkit/LoadListener.java | 6 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewDatabase.java | 19 |
4 files changed, 40 insertions, 14 deletions
diff --git a/core/java/android/webkit/CacheLoader.java b/core/java/android/webkit/CacheLoader.java index 3e1b602..de8f888 100644 --- a/core/java/android/webkit/CacheLoader.java +++ b/core/java/android/webkit/CacheLoader.java @@ -17,6 +17,7 @@ package android.webkit; import android.net.http.Headers; +import android.text.TextUtils; /** * This class is a concrete implementation of StreamLoader that uses a @@ -49,17 +50,22 @@ class CacheLoader extends StreamLoader { @Override protected void buildHeaders(Headers headers) { StringBuilder sb = new StringBuilder(mCacheResult.mimeType); - if (mCacheResult.encoding != null && - mCacheResult.encoding.length() > 0) { + if (!TextUtils.isEmpty(mCacheResult.encoding)) { sb.append(';'); sb.append(mCacheResult.encoding); } headers.setContentType(sb.toString()); - if (mCacheResult.location != null && - mCacheResult.location.length() > 0) { + if (!TextUtils.isEmpty(mCacheResult.location)) { headers.setLocation(mCacheResult.location); } - } + if (!TextUtils.isEmpty(mCacheResult.expiresString)) { + headers.setExpires(mCacheResult.expiresString); + } + + if (!TextUtils.isEmpty(mCacheResult.contentdisposition)) { + headers.setContentDisposition(mCacheResult.contentdisposition); + } + } } diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java index fb9edb9..9a02fbe 100644 --- a/core/java/android/webkit/CacheManager.java +++ b/core/java/android/webkit/CacheManager.java @@ -86,6 +86,7 @@ public final class CacheManager { String mimeType; String location; String encoding; + String contentdisposition; // these fields are NOT saved to the database InputStream inStream; @@ -135,6 +136,13 @@ public final class CacheManager { return encoding; } + /** + * @hide Pending API council approval + */ + public String getContentDisposition() { + return contentdisposition; + } + // For out-of-package access to the underlying streams. public InputStream getInputStream() { return inStream; @@ -627,6 +635,11 @@ public final class CacheManager { } } + String contentDisposition = headers.getContentDisposition(); + if (contentDisposition != null) { + ret.contentdisposition = contentDisposition; + } + String lastModified = headers.getLastModified(); if (lastModified != null) ret.lastModified = lastModified; diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java index a87a5c2..6f228a4 100644 --- a/core/java/android/webkit/LoadListener.java +++ b/core/java/android/webkit/LoadListener.java @@ -948,8 +948,7 @@ class LoadListener extends Handler implements EventHandler { // pass content-type content-length and content-encoding final int nativeResponse = nativeCreateResponse( mUrl, statusCode, mStatusText, - mMimeType, mContentLength, mEncoding, - mCacheResult == null ? null : mCacheResult.expiresString); + mMimeType, mContentLength, mEncoding); if (mHeaders != null) { mHeaders.getHeaders(new Headers.HeaderCallback() { public void header(String name, String value) { @@ -1460,12 +1459,11 @@ class LoadListener extends Handler implements EventHandler { * @param expectedLength An estimate of the content length or the length * given by the server. * @param encoding HTTP encoding. - * @param expireTime HTTP expires. * @return The native response pointer. */ private native int nativeCreateResponse(String url, int statusCode, String statusText, String mimeType, long expectedLength, - String encoding, String expireTime); + String encoding); /** * Add a response header to the native object. diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java index e6d89e3..4e76254 100644 --- a/core/java/android/webkit/WebViewDatabase.java +++ b/core/java/android/webkit/WebViewDatabase.java @@ -48,8 +48,9 @@ public class WebViewDatabase { // 6 -> 7 Change cache localPath from int to String // 7 -> 8 Move cache to its own db // 8 -> 9 Store both scheme and host when storing passwords - private static final int CACHE_DATABASE_VERSION = 2; + private static final int CACHE_DATABASE_VERSION = 3; // 1 -> 2 Add expires String + // 2 -> 3 Add content-disposition private static WebViewDatabase mInstance = null; @@ -120,6 +121,8 @@ public class WebViewDatabase { private static final String CACHE_CONTENTLENGTH_COL = "contentlength"; + private static final String CACHE_CONTENTDISPOSITION_COL = "contentdisposition"; + // column id strings for "password" table private static final String PASSWORD_HOST_COL = "host"; @@ -159,6 +162,7 @@ public class WebViewDatabase { private static int mCacheHttpStatusColIndex; private static int mCacheLocationColIndex; private static int mCacheContentLengthColIndex; + private static int mCacheContentDispositionColIndex; private static int mCacheTransactionRefcount; @@ -236,6 +240,8 @@ public class WebViewDatabase { .getColumnIndex(CACHE_LOCATION_COL); mCacheContentLengthColIndex = mCacheInserter .getColumnIndex(CACHE_CONTENTLENGTH_COL); + mCacheContentDispositionColIndex = mCacheInserter + .getColumnIndex(CACHE_CONTENTDISPOSITION_COL); } } @@ -330,8 +336,8 @@ public class WebViewDatabase { + CACHE_MIMETYPE_COL + " TEXT, " + CACHE_ENCODING_COL + " TEXT," + CACHE_HTTP_STATUS_COL + " INTEGER, " + CACHE_LOCATION_COL + " TEXT, " + CACHE_CONTENTLENGTH_COL - + " INTEGER, " + " UNIQUE (" + CACHE_URL_COL - + ") ON CONFLICT REPLACE);"); + + " INTEGER, " + CACHE_CONTENTDISPOSITION_COL + " TEXT, " + + " UNIQUE (" + CACHE_URL_COL + ") ON CONFLICT REPLACE);"); mCacheDatabase.execSQL("CREATE INDEX cacheUrlIndex ON cache (" + CACHE_URL_COL + ")"); } @@ -544,8 +550,8 @@ public class WebViewDatabase { } Cursor cursor = mCacheDatabase.rawQuery("SELECT filepath, lastmodify, etag, expires, " - + "expiresstring, mimetype, encoding, httpstatus, location, contentlength " - + "FROM cache WHERE url = ?", + + "expiresstring, mimetype, encoding, httpstatus, location, contentlength, " + + "contentdisposition FROM cache WHERE url = ?", new String[] { url }); try { @@ -561,6 +567,7 @@ public class WebViewDatabase { ret.httpStatusCode = cursor.getInt(7); ret.location = cursor.getString(8); ret.contentLength = cursor.getLong(9); + ret.contentdisposition = cursor.getString(10); return ret; } } finally { @@ -605,6 +612,8 @@ public class WebViewDatabase { mCacheInserter.bind(mCacheHttpStatusColIndex, c.httpStatusCode); mCacheInserter.bind(mCacheLocationColIndex, c.location); mCacheInserter.bind(mCacheContentLengthColIndex, c.contentLength); + mCacheInserter.bind(mCacheContentDispositionColIndex, + c.contentdisposition); mCacheInserter.execute(); } |