Parsing feeds which have a text/html content-type

This commit is contained in:
Shinokuni 2019-02-06 13:15:40 +00:00
parent edbff99c4f
commit f384d5b9c8
2 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@ public final class Utils {
public static final String RSS_APPLICATION_CONTENT_TYPE = "application/xml";
public static final String ATOM_CONTENT_TYPE = "application/atom+xml";
public static final String JSON_CONTENT_TYPE = "application/json";
public static final String HTML_CONTENT_TYPE = "text/html";
public static String inputStreamToString(InputStream input) {
Scanner scanner = new Scanner(input).useDelimiter("\\A");

View File

@ -54,7 +54,7 @@ public class RSSNetwork {
if (response.isSuccessful()) {
RSSType type = getRSSType(header);
if (type == null) {
callback.onSyncFailure(new IllegalArgumentException("bad content type"));
callback.onSyncFailure(new IllegalArgumentException("bad content type : " + header + "for " + url));
return;
}
@ -123,6 +123,8 @@ public class RSSNetwork {
return RSSType.RSS_ATOM;
case Utils.JSON_CONTENT_TYPE:
return RSSType.RSS_JSON;
case Utils.HTML_CONTENT_TYPE:
return RSSType.RSS_UNKNOWN;
default:
Log.d(TAG, "bad content type : " + contentType);
return null;