return error MEDIA_ERROR_UNSUPPORTED when Range request fail
Bug: 18235751
Change-Id: I4631daf50bb76b70dd740c45b628294ad1aa45e1
diff --git a/media/java/android/media/MediaHTTPConnection.java b/media/java/android/media/MediaHTTPConnection.java
index d0f3334..b2886bb 100644
--- a/media/java/android/media/MediaHTTPConnection.java
+++ b/media/java/android/media/MediaHTTPConnection.java
@@ -31,6 +31,7 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.NoRouteToHostException;
+import java.net.ProtocolException;
import java.util.HashMap;
import java.util.Map;
@@ -282,7 +283,7 @@
if (offset > 0 && response != HttpURLConnection.HTTP_PARTIAL) {
// Some servers simply ignore "Range" requests and serve
// data from the start of the content.
- throw new IOException();
+ throw new ProtocolException();
}
mInputStream =
@@ -330,6 +331,9 @@
}
return n;
+ } catch (ProtocolException e) {
+ Log.w(TAG, "readAt " + offset + " / " + size + " => " + e);
+ return MEDIA_ERROR_UNSUPPORTED;
} catch (NoRouteToHostException e) {
Log.w(TAG, "readAt " + offset + " / " + size + " => " + e);
return MEDIA_ERROR_UNSUPPORTED;