and I'm hitting a new page (i.e., page > 1), then the resulting URL ends up as:
http://foo.bar.com/news?format=rss?paged=2
This causes the request to fail.
I've re-written the method (using Kotlin - but I'm sure should be easy enough to convert to Java), that uses the inbuilt URI builder to cope with query parameters.
import android.content.Context
import android.net.Uri
import com.pkmmte.pkrss.Request
import com.pkmmte.pkrss.downloader.OkHttpDownloader
class CorrectedOkHttpDownloader(context: Context) : OkHttpDownloader(context) {
override fun toUrl(request: Request): String {
var uriBuilder = Uri.parse(request.url).buildUpon()
if (request.individual) {
uriBuilder
.appendPath("feed")
.appendQueryParameter("withoutcomments", "1")
} else {
if (request.search != null) {
uriBuilder.appendQueryParameter("s", Uri.encode(request.search))
}
if (request.page > 1) {
val page = request.page
uriBuilder.appendQueryParameter("paged", "$page")
}
}
return uriBuilder.build().toString()
}
}
Hi,
If I have a URI of the form:
and I'm hitting a new page (i.e., page > 1), then the resulting URL ends up as:
This causes the request to fail.
I've re-written the method (using Kotlin - but I'm sure should be easy enough to convert to Java), that uses the inbuilt URI builder to cope with query parameters.
Hope this helps!
-=david=-