From 99b438e4c4fa1b40653c0da07d9fff2479777a9d Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Fri, 19 Dec 2014 12:06:00 +0000 Subject: [PATCH] Don't request that the server use DEFLATE compression. If the server actually gives us a DEFLATE response, we fail to handle it properly! --- .../android/exoplayer/upstream/HttpDataSource.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java index 164820654c..e479477561 100644 --- a/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java +++ b/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java @@ -226,6 +226,19 @@ public class HttpDataSource implements DataSource { } } + /* + * TODO: If the server uses gzip compression when serving the response, this may end up returning + * the size of the compressed response, where-as it should be returning the decompressed size or + * -1. See: developer.android.com/reference/java/net/HttpURLConnection.html + * + * To fix this we should: + * + * 1. Explicitly require no compression for media requests (since media should be compressed + * already) by setting the Accept-Encoding header to "identity" + * 2. In other cases, for example when requesting manifests, we don't want to disable compression. + * For these cases we should ensure that we return -1 here (and avoid performing any sanity + * checks on the content length). + */ @Override public long open(DataSpec dataSpec) throws HttpDataSourceException { this.dataSpec = dataSpec; @@ -380,7 +393,6 @@ public class HttpDataSource implements DataSource { connection.setRequestProperty(property.getKey(), property.getValue()); } } - connection.setRequestProperty("Accept-Encoding", "deflate"); connection.setRequestProperty("User-Agent", userAgent); connection.setRequestProperty("Range", buildRangeHeader(dataSpec)); connection.connect();