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.
This commit is contained in:
parent
625c46e963
commit
15a59d93ee
@ -304,14 +304,14 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
|
|
||||||
// Check for a valid response code.
|
// Check for a valid response code.
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
|
Map<String, List<String>> headers = response.headers().toMultimap();
|
||||||
byte[] errorResponseBody;
|
byte[] errorResponseBody;
|
||||||
try {
|
try {
|
||||||
errorResponseBody = Util.toByteArray(Assertions.checkNotNull(responseByteStream));
|
errorResponseBody = Util.toByteArray(Assertions.checkNotNull(responseByteStream));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new HttpDataSourceException(
|
throw new InvalidResponseCodeException(
|
||||||
"Error reading non-2xx response body", e, dataSpec, HttpDataSourceException.TYPE_OPEN);
|
responseCode, response.message(), headers, dataSpec, null);
|
||||||
}
|
}
|
||||||
Map<String, List<String>> headers = response.headers().toMultimap();
|
|
||||||
closeConnectionQuietly();
|
closeConnectionQuietly();
|
||||||
InvalidResponseCodeException exception =
|
InvalidResponseCodeException exception =
|
||||||
new InvalidResponseCodeException(
|
new InvalidResponseCodeException(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user