diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-11-01 11:15:13 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-11-01 11:15:13 -0700 |
commit | e80fbcb19a486400013e85c53b112057fdaa48bb (patch) | |
tree | 5f20b6bd9123e1cd6f0ee6c997d41002848142c8 /src | |
parent | fb3017ffd8aa3f2342380270cf468e3a68914e69 (diff) | |
parent | 8adc828f4df3f3856f42750ccf2892ba27c93d86 (diff) | |
download | packages_apps_Browser-e80fbcb19a486400013e85c53b112057fdaa48bb.zip packages_apps_Browser-e80fbcb19a486400013e85c53b112057fdaa48bb.tar.gz packages_apps_Browser-e80fbcb19a486400013e85c53b112057fdaa48bb.tar.bz2 |
resolved conflicts for merge of 8adc828f to master
Change-Id: I55678d34730df191d541762d4b2025bff2f2460b
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/FetchUrlMimeType.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/com/android/browser/FetchUrlMimeType.java b/src/com/android/browser/FetchUrlMimeType.java index 4e2733f..89ac13d 100644 --- a/src/com/android/browser/FetchUrlMimeType.java +++ b/src/com/android/browser/FetchUrlMimeType.java @@ -48,7 +48,7 @@ import android.webkit.URLUtil; * android.os.webkit.LoadListener rather than handling it here. * */ -class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { +class FetchUrlMimeType extends AsyncTask<ContentValues, String, ContentValues> { public static final String URI = "uri"; public static final String USER_AGENT = "user_agent"; @@ -64,7 +64,7 @@ class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { } @Override - public String doInBackground(ContentValues... values) { + public ContentValues doInBackground(ContentValues... values) { mValues = values[0]; // Check to make sure we have a URI to download @@ -89,7 +89,7 @@ class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { } HttpResponse response; - String mimeType = null; + ContentValues result = new ContentValues(); try { response = client.execute(request); // We could get a redirect here, but if we do lets let @@ -98,11 +98,16 @@ class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { if (response.getStatusLine().getStatusCode() == 200) { Header header = response.getFirstHeader("Content-Type"); if (header != null) { - mimeType = header.getValue(); + String mimeType = header.getValue(); final int semicolonIndex = mimeType.indexOf(';'); if (semicolonIndex != -1) { mimeType = mimeType.substring(0, semicolonIndex); } + result.put("Content-Type", mimeType); + } + Header contentDispositionHeader = response.getFirstHeader("Content-Disposition"); + if (contentDispositionHeader != null) { + result.put("Content-Disposition", contentDispositionHeader.getValue()); } } } catch (IllegalArgumentException ex) { @@ -113,11 +118,13 @@ class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { client.close(); } - return mimeType; + return result; } @Override - public void onPostExecute(String mimeType) { + public void onPostExecute(ContentValues values) { + final String mimeType = values.getAsString("Content-Type"); + final String contentDisposition = values.getAsString("Content-Disposition"); if (mimeType != null) { String url = mValues.getAsString(URI); if (mimeType.equalsIgnoreCase("text/plain") || @@ -130,7 +137,7 @@ class FetchUrlMimeType extends AsyncTask<ContentValues, String, String> { } } String filename = URLUtil.guessFileName(url, - null, mimeType); + contentDisposition, mimeType); mRequest.setDestinationInExternalFilesDir(mActivity, null, filename); } |