Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure RSS feeds can be identified even if the <channel> element does…

… not have a <link> element.
  • Loading branch information...
commit 05107db8c9d58df5af384e2858a57a32ba9dbdb9 1 parent abe1f4c
@ahorn authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/main/java/org/mcsoxford/rss/RSSReader.java
View
14 src/main/java/org/mcsoxford/rss/RSSReader.java
@@ -88,7 +88,7 @@ public RSSReader(RSSConfig config) {
public RSSFeed load(String uri) throws RSSReaderException {
final HttpGet httpget = new HttpGet(uri);
- InputStream feed = null;
+ InputStream feedStream = null;
try {
// Send GET request to URI
final HttpResponse response = httpclient.execute(httpget);
@@ -102,15 +102,21 @@ public RSSFeed load(String uri) throws RSSReaderException {
// Extract content stream from HTTP response
HttpEntity entity = response.getEntity();
- feed = entity.getContent();
+ feedStream = entity.getContent();
- return parser.parse(feed);
+ RSSFeed feed = parser.parse(feedStream);
+
+ if (feed.getLink() == null) {
+ feed.setLink(android.net.Uri.parse(uri));
+ }
+
+ return feed;
} catch (ClientProtocolException e) {
throw new RSSFault(e);
} catch (IOException e) {
throw new RSSFault(e);
} finally {
- Resources.closeQuietly(feed);
+ Resources.closeQuietly(feedStream);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.