Commit 15a59d93 by Emanuele Tidó Committed by GitHub

throw exception improved

if responseCode and responseMessage ara available always throws an InvalidResponseCodeException instead of HttpDataSourceException, so in onPlayerError method the http status code and message can be used to decide what will be the next step.
parent 625c46e9
......@@ -304,14 +304,14 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
// Check for a valid response code.
if (!response.isSuccessful()) {
Map<String, List<String>> headers = response.headers().toMultimap();
byte[] errorResponseBody;
try {
errorResponseBody = Util.toByteArray(Assertions.checkNotNull(responseByteStream));
} catch (IOException e) {
throw new HttpDataSourceException(
"Error reading non-2xx response body", e, dataSpec, HttpDataSourceException.TYPE_OPEN);
throw new InvalidResponseCodeException(
responseCode, response.message(), headers, dataSpec, null);
}
Map<String, List<String>> headers = response.headers().toMultimap();
closeConnectionQuietly();
InvalidResponseCodeException exception =
new InvalidResponseCodeException(
......
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