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 RSS_APPLICATION_CONTENT_TYPE = "application/xml";
public static final String ATOM_CONTENT_TYPE = "application/atom+xml"; public static final String ATOM_CONTENT_TYPE = "application/atom+xml";
public static final String JSON_CONTENT_TYPE = "application/json"; public static final String JSON_CONTENT_TYPE = "application/json";
public static final String HTML_CONTENT_TYPE = "text/html";
public static String inputStreamToString(InputStream input) { public static String inputStreamToString(InputStream input) {
Scanner scanner = new Scanner(input).useDelimiter("\\A"); Scanner scanner = new Scanner(input).useDelimiter("\\A");

View File

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