mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
CB-9343 Split the Content-Type to obtain a clean mimetype
This closes #197
This commit is contained in:
parent
92caa3a186
commit
fab472859d
@ -188,7 +188,11 @@ public class CordovaResourceApi {
|
|||||||
HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
|
HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
|
||||||
conn.setDoInput(false);
|
conn.setDoInput(false);
|
||||||
conn.setRequestMethod("HEAD");
|
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) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,6 +287,9 @@ public class CordovaResourceApi {
|
|||||||
HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
|
HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
String mimeType = conn.getHeaderField("Content-Type");
|
String mimeType = conn.getHeaderField("Content-Type");
|
||||||
|
if (mimeType != null) {
|
||||||
|
mimeType = mimeType.split(";")[0];
|
||||||
|
}
|
||||||
int length = conn.getContentLength();
|
int length = conn.getContentLength();
|
||||||
InputStream inputStream = conn.getInputStream();
|
InputStream inputStream = conn.getInputStream();
|
||||||
return new OpenForReadResult(uri, inputStream, mimeType, length, null);
|
return new OpenForReadResult(uri, inputStream, mimeType, length, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user