Fix url being rewritten for not freshrss/nextcloud news http calls

This commit is contained in:
Shinokuni 2020-10-25 11:56:20 +01:00
parent e37853a619
commit 39e613e7e6
3 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import androidx.annotation.WorkerThread
import com.readrops.api.localfeed.json.JSONFeedAdapter
import com.readrops.api.localfeed.json.JSONItemsAdapter
import com.readrops.api.utils.ApiUtils
import com.readrops.api.utils.AuthInterceptor
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.exceptions.UnknownFormatException
import com.readrops.db.entities.Feed
@ -16,12 +17,14 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okio.Buffer
import org.koin.core.KoinComponent
import org.koin.core.get
import java.io.ByteArrayInputStream
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
class LocalRSSDataSource(private val httpClient: OkHttpClient) {
class LocalRSSDataSource(private val httpClient: OkHttpClient): KoinComponent {
/**
* Query RSS url
@ -32,6 +35,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) {
@Throws(ParseException::class, UnknownFormatException::class, NetworkErrorException::class, IOException::class)
@WorkerThread
fun queryRSSResource(url: String, headers: Headers?): Pair<Feed, List<Item>>? {
get<AuthInterceptor>().credentials = null
val response = queryUrl(url, headers)
return when {

View File

@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
import com.readrops.api.localfeed.LocalRSSHelper;
import com.readrops.api.utils.ApiUtils;
import com.readrops.api.utils.AuthInterceptor;
import com.readrops.app.addfeed.ParsingResult;
import org.jsoup.Jsoup;
@ -87,6 +88,7 @@ public final class HtmlParser {
try {
Response response = KoinJavaComponent.get(OkHttpClient.class)
.newCall(new Request.Builder().url(url).build()).execute();
KoinJavaComponent.get(AuthInterceptor.class).setCredentials(null);
if (response.header("Content-Type").contains(ApiUtils.HTML_CONTENT_TYPE)) {
String body = response.body().string();

View File

@ -15,6 +15,7 @@ import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import com.google.android.material.snackbar.Snackbar;
import com.readrops.api.utils.AuthInterceptor;
import org.koin.java.KoinJavaComponent;
@ -36,6 +37,7 @@ public final class Utils {
public static Bitmap getImageFromUrl(String url) {
try {
Request request = new Request.Builder().url(url).build();
KoinJavaComponent.get(AuthInterceptor.class).setCredentials(null);
Response response = KoinJavaComponent.get(OkHttpClient.class).newCall(request).execute();