From 3167c7a5d2333d94b81edc6d6b567bd4facad1ed Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 16 Mar 2020 01:09:32 +0100 Subject: [PATCH] Always add UserAgent to requests --- .../discovery/ItunesPodcastSearcher.java | 3 +-- .../discovery/ItunesTopListLoader.java | 4 +--- .../core/glide/ChapterImageModelLoader.java | 1 - .../core/gpoddernet/GpodnetService.java | 7 +++---- .../core/service/UserAgentInterceptor.java | 20 +++++++++++++++++++ .../download/AntennapodHttpClient.java | 2 ++ .../core/service/download/HttpDownloader.java | 3 +-- 7 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/de/danoeh/antennapod/core/service/UserAgentInterceptor.java diff --git a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesPodcastSearcher.java b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesPodcastSearcher.java index a91aae1a8..620b30177 100644 --- a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesPodcastSearcher.java +++ b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesPodcastSearcher.java @@ -43,8 +43,7 @@ public class ItunesPodcastSearcher implements PodcastSearcher { OkHttpClient client = AntennapodHttpClient.getHttpClient(); Request.Builder httpReq = new Request.Builder() - .url(formattedUrl) - .header("User-Agent", ClientConfig.USER_AGENT); + .url(formattedUrl); List podcasts = new ArrayList<>(); try { Response response = client.newCall(httpReq.build()).execute(); diff --git a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java index bb0e165b7..eb6589b84 100644 --- a/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java +++ b/app/src/main/java/de/danoeh/antennapod/discovery/ItunesTopListLoader.java @@ -57,8 +57,7 @@ public class ItunesTopListLoader { return Single.create((SingleOnSubscribe) emitter -> { OkHttpClient client = AntennapodHttpClient.getHttpClient(); Request.Builder httpReq = new Request.Builder() - .url(podcast.feedUrl) - .header("User-Agent", ClientConfig.USER_AGENT); + .url(podcast.feedUrl); try { Response response = client.newCall(httpReq.build()).execute(); if (response.isSuccessful()) { @@ -84,7 +83,6 @@ public class ItunesTopListLoader { Log.d(TAG, "Feed URL " + String.format(url, country)); Request.Builder httpReq = new Request.Builder() .cacheControl(new CacheControl.Builder().minFresh(1, TimeUnit.DAYS).build()) - .header("User-Agent", ClientConfig.USER_AGENT) .url(String.format(url, country)); try (Response response = client.newCall(httpReq.build()).execute()) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java b/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java index bc0a06a07..36da11eca 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java @@ -71,7 +71,6 @@ public final class ChapterImageModelLoader implements ModelLoader