Commit 3e62b63e by Oliver Woodman

Try and use httpDataSource if scheme isn't recognised.

Issue: #473
parent 253a0105
...@@ -36,28 +36,6 @@ import java.io.IOException; ...@@ -36,28 +36,6 @@ import java.io.IOException;
*/ */
public final class DefaultUriDataSource implements UriDataSource { public final class DefaultUriDataSource implements UriDataSource {
/**
* Thrown when a {@link DefaultUriDataSource} is opened for a URI with an unsupported scheme.
*/
public static final class UnsupportedSchemeException extends IOException {
/**
* The unsupported scheme.
*/
public final String scheme;
/**
* @param scheme The unsupported scheme.
*/
public UnsupportedSchemeException(String scheme) {
super("Unsupported URI scheme: " + scheme);
this.scheme = scheme;
}
}
private static final String SCHEME_HTTP = "http";
private static final String SCHEME_HTTPS = "https";
private static final String SCHEME_FILE = "file"; private static final String SCHEME_FILE = "file";
private static final String SCHEME_ASSET = "asset"; private static final String SCHEME_ASSET = "asset";
private static final String SCHEME_CONTENT = "content"; private static final String SCHEME_CONTENT = "content";
...@@ -141,9 +119,7 @@ public final class DefaultUriDataSource implements UriDataSource { ...@@ -141,9 +119,7 @@ public final class DefaultUriDataSource implements UriDataSource {
Assertions.checkState(dataSource == null); Assertions.checkState(dataSource == null);
// Choose the correct source for the scheme. // Choose the correct source for the scheme.
String scheme = dataSpec.uri.getScheme(); String scheme = dataSpec.uri.getScheme();
if (SCHEME_HTTP.equals(scheme) || SCHEME_HTTPS.equals(scheme)) { if (SCHEME_FILE.equals(scheme) || TextUtils.isEmpty(scheme)) {
dataSource = httpDataSource;
} else if (SCHEME_FILE.equals(scheme) || TextUtils.isEmpty(scheme)) {
if (dataSpec.uri.getPath().startsWith("/android_asset/")) { if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
dataSource = assetDataSource; dataSource = assetDataSource;
} else { } else {
...@@ -154,7 +130,7 @@ public final class DefaultUriDataSource implements UriDataSource { ...@@ -154,7 +130,7 @@ public final class DefaultUriDataSource implements UriDataSource {
} else if (SCHEME_CONTENT.equals(scheme)) { } else if (SCHEME_CONTENT.equals(scheme)) {
dataSource = contentDataSource; dataSource = contentDataSource;
} else { } else {
throw new UnsupportedSchemeException(scheme); dataSource = httpDataSource;
} }
// Open the source and return. // Open the source and return.
return dataSource.open(dataSpec); return dataSource.open(dataSpec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment