mirror of https://github.com/readrops/Readrops.git
Fix content-type not being parsed when getting url rss type
This commit is contained in:
parent
eb58311040
commit
ec53cbd683
|
@ -167,7 +167,7 @@ class LocalRSSDataSourceTest {
|
||||||
@Test
|
@Test
|
||||||
fun isUrlResourceSuccessfulTest() {
|
fun isUrlResourceSuccessfulTest() {
|
||||||
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
||||||
.addHeader("Content-Type", "application/atom+xml"))
|
.addHeader("Content-Type", "application/atom+xml; charset=UTF-8"))
|
||||||
|
|
||||||
assertTrue(localRSSDataSource.isUrlRSSResource(url.toString()))
|
assertTrue(localRSSDataSource.isUrlRSSResource(url.toString()))
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ class LocalRSSDataSourceTest {
|
||||||
@Test
|
@Test
|
||||||
fun isUrlRSSResourceBadContentTypeTest() {
|
fun isUrlRSSResourceBadContentTypeTest() {
|
||||||
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)
|
||||||
.addHeader("Content-Type", "application/xml")
|
.addHeader("Content-Type", "application/xml; charset=UTF-8")
|
||||||
.setBody("<html> </html>"))
|
.setBody("<html> </html>"))
|
||||||
|
|
||||||
assertFalse(localRSSDataSource.isUrlRSSResource(url.toString()))
|
assertFalse(localRSSDataSource.isUrlRSSResource(url.toString()))
|
||||||
|
|
|
@ -73,7 +73,10 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) {
|
||||||
val response = queryUrl(url, null)
|
val response = queryUrl(url, null)
|
||||||
|
|
||||||
return if (response.isSuccessful) {
|
return if (response.isSuccessful) {
|
||||||
val contentType = response.header(LibUtils.CONTENT_TYPE_HEADER)
|
val header = response.header(LibUtils.CONTENT_TYPE_HEADER)
|
||||||
|
?: return false
|
||||||
|
|
||||||
|
val contentType = LibUtils.parseContentType(header)
|
||||||
?: return false
|
?: return false
|
||||||
|
|
||||||
var type = LocalRSSHelper.getRSSType(contentType)
|
var type = LocalRSSHelper.getRSSType(contentType)
|
||||||
|
|
Loading…
Reference in New Issue