OSDN Git Service

return error MEDIA_ERROR_UNSUPPORTED when Range request fail
authorChong Zhang <chz@google.com>
Tue, 11 Nov 2014 03:31:01 +0000 (19:31 -0800)
committerChong Zhang <chz@google.com>
Tue, 11 Nov 2014 03:32:28 +0000 (19:32 -0800)
Bug: 18235751
Change-Id: I4631daf50bb76b70dd740c45b628294ad1aa45e1

media/java/android/media/MediaHTTPConnection.java

index d0f3334..b2886bb 100644 (file)
@@ -31,6 +31,7 @@ import java.net.URL;
 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 @@ public class MediaHTTPConnection extends IMediaHTTPConnection.Stub {
             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 @@ public class MediaHTTPConnection extends IMediaHTTPConnection.Stub {
             }
 
             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;