mirror of https://github.com/readrops/Readrops.git
Fix url being rewritten for not freshrss/nextcloud news http calls
This commit is contained in:
parent
e37853a619
commit
39e613e7e6
|
@ -5,6 +5,7 @@ import androidx.annotation.WorkerThread
|
||||||
import com.readrops.api.localfeed.json.JSONFeedAdapter
|
import com.readrops.api.localfeed.json.JSONFeedAdapter
|
||||||
import com.readrops.api.localfeed.json.JSONItemsAdapter
|
import com.readrops.api.localfeed.json.JSONItemsAdapter
|
||||||
import com.readrops.api.utils.ApiUtils
|
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.ParseException
|
||||||
import com.readrops.api.utils.exceptions.UnknownFormatException
|
import com.readrops.api.utils.exceptions.UnknownFormatException
|
||||||
import com.readrops.db.entities.Feed
|
import com.readrops.db.entities.Feed
|
||||||
|
@ -16,12 +17,14 @@ import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okio.Buffer
|
import okio.Buffer
|
||||||
|
import org.koin.core.KoinComponent
|
||||||
|
import org.koin.core.get
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
|
|
||||||
class LocalRSSDataSource(private val httpClient: OkHttpClient) {
|
class LocalRSSDataSource(private val httpClient: OkHttpClient): KoinComponent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query RSS url
|
* Query RSS url
|
||||||
|
@ -32,6 +35,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) {
|
||||||
@Throws(ParseException::class, UnknownFormatException::class, NetworkErrorException::class, IOException::class)
|
@Throws(ParseException::class, UnknownFormatException::class, NetworkErrorException::class, IOException::class)
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun queryRSSResource(url: String, headers: Headers?): Pair<Feed, List<Item>>? {
|
fun queryRSSResource(url: String, headers: Headers?): Pair<Feed, List<Item>>? {
|
||||||
|
get<AuthInterceptor>().credentials = null
|
||||||
val response = queryUrl(url, headers)
|
val response = queryUrl(url, headers)
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.readrops.api.localfeed.LocalRSSHelper;
|
import com.readrops.api.localfeed.LocalRSSHelper;
|
||||||
import com.readrops.api.utils.ApiUtils;
|
import com.readrops.api.utils.ApiUtils;
|
||||||
|
import com.readrops.api.utils.AuthInterceptor;
|
||||||
import com.readrops.app.addfeed.ParsingResult;
|
import com.readrops.app.addfeed.ParsingResult;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
@ -87,6 +88,7 @@ public final class HtmlParser {
|
||||||
try {
|
try {
|
||||||
Response response = KoinJavaComponent.get(OkHttpClient.class)
|
Response response = KoinJavaComponent.get(OkHttpClient.class)
|
||||||
.newCall(new Request.Builder().url(url).build()).execute();
|
.newCall(new Request.Builder().url(url).build()).execute();
|
||||||
|
KoinJavaComponent.get(AuthInterceptor.class).setCredentials(null);
|
||||||
|
|
||||||
if (response.header("Content-Type").contains(ApiUtils.HTML_CONTENT_TYPE)) {
|
if (response.header("Content-Type").contains(ApiUtils.HTML_CONTENT_TYPE)) {
|
||||||
String body = response.body().string();
|
String body = response.body().string();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.readrops.api.utils.AuthInterceptor;
|
||||||
|
|
||||||
import org.koin.java.KoinJavaComponent;
|
import org.koin.java.KoinJavaComponent;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ public final class Utils {
|
||||||
public static Bitmap getImageFromUrl(String url) {
|
public static Bitmap getImageFromUrl(String url) {
|
||||||
try {
|
try {
|
||||||
Request request = new Request.Builder().url(url).build();
|
Request request = new Request.Builder().url(url).build();
|
||||||
|
KoinJavaComponent.get(AuthInterceptor.class).setCredentials(null);
|
||||||
|
|
||||||
Response response = KoinJavaComponent.get(OkHttpClient.class).newCall(request).execute();
|
Response response = KoinJavaComponent.get(OkHttpClient.class).newCall(request).execute();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue