summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorMartin Fietz <Martin.Fietz@gmail.com>2016-06-24 11:24:30 +0200
committerMartin Fietz <Martin.Fietz@gmail.com>2016-06-24 11:24:30 +0200
commit4b79afc2b0d9d8191aa5d2d363373342631691b5 (patch)
treea22c0f00dad5d049a8ca92d105eeb831d7a116d8 /core/src
parent5f1ca9bc5728fdfb2a308d8f214d07c9687e9d62 (diff)
downloadAntennaPod-4b79afc2b0d9d8191aa5d2d363373342631691b5.zip
Add exponential backoff for file type errors and check content length before assuming a file type error
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java3
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java12
2 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index f773cdf2a..7df41a9d3 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -208,7 +208,8 @@ public class DownloadService extends Service {
boolean forbidden = status.getReason() == DownloadError.ERROR_FORBIDDEN
&& String.valueOf(HttpURLConnection.HTTP_FORBIDDEN).equals(status.getReasonDetailed());
boolean notEnoughSpace = status.getReason() == DownloadError.ERROR_NOT_ENOUGH_SPACE;
- if (httpNotFound || forbidden || notEnoughSpace) {
+ boolean wrongFileType = status.getReason() == DownloadError.ERROR_FILE_TYPE;
+ if (httpNotFound || forbidden || notEnoughSpace || wrongFileType) {
DBWriter.saveFeedItemAutoDownloadFailed(item).get();
}
// to make lists reload the failed item, we fake an item update
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
index 94a722da9..c259f16a2 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java
@@ -182,10 +182,20 @@ public class HttpDownloader extends Downloader {
return;
}
+ // fail with a file type error when the content type is text and
+ // the reported content length is less than 100kb (or no length is given)
if(request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
String contentType = response.header("Content-Type");
Log.d(TAG, "content type: " + contentType);
- if(contentType.startsWith("text/")) {
+ int contentLength = -1;
+ String contentLen = response.header("Content-Length");
+ if(contentLen != null) {
+ try {
+ contentLength = Integer.parseInt(contentLen);
+ } catch(NumberFormatException e) {}
+ }
+ Log.d(TAG, "content length: " + contentLength);
+ if(contentType.startsWith("text/") && contentLength < 100 * 1024) {
onFail(DownloadError.ERROR_FILE_TYPE, null);
return;
}