cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [12/45] android commit: CB-9343 Split the Content-Type to obtain a clean mimetype
Date Wed, 23 Sep 2015 19:58:23 GMT
CB-9343 Split the Content-Type to obtain a clean mimetype

This closes #197


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/662429ad
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/662429ad
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/662429ad

Branch: refs/heads/5.0.x
Commit: 662429ad98d828aa70704c552de9019ed46f9a6f
Parents: c5557f7
Author: Simon Pireyn <spireyn@gmail.com>
Authored: Thu Jul 9 20:00:10 2015 +0200
Committer: Joe Bowser <bowserj@apache.org>
Committed: Thu Aug 20 13:48:02 2015 -0700

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaResourceApi.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/662429ad/framework/src/org/apache/cordova/CordovaResourceApi.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java
index 0390bb0..e725e25 100644
--- a/framework/src/org/apache/cordova/CordovaResourceApi.java
+++ b/framework/src/org/apache/cordova/CordovaResourceApi.java
@@ -188,7 +188,11 @@ public class CordovaResourceApi {
                     HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
                     conn.setDoInput(false);
                     conn.setRequestMethod("HEAD");
-                    return conn.getHeaderField("Content-Type");
+                    String mimeType = conn.getHeaderField("Content-Type");
+                    if (mimeType != null) {
+                        mimeType = mimeType.split(";")[0];
+                    }
+                    return mimeType;
                 } catch (IOException e) {
                 }
             }
@@ -283,6 +287,9 @@ public class CordovaResourceApi {
                 HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
                 conn.setDoInput(true);
                 String mimeType = conn.getHeaderField("Content-Type");
+                if (mimeType != null) {
+                    mimeType = mimeType.split(";")[0];
+                }
                 int length = conn.getContentLength();
                 InputStream inputStream = conn.getInputStream();
                 return new OpenForReadResult(uri, inputStream, mimeType, length, null);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message