Specifies acceptable content types in connection request header; fix for Bug 8775. RCL_2_0
authorstechong
Mon, 13 Apr 2009 13:34:20 -0500
branchRCL_2_0
changeset 83 6c6d4b0c9171
parent 82 8839c373a1c1
child 85 ff7a6e6a0de4
Specifies acceptable content types in connection request header; fix for Bug 8775.
core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/CarbideFeedFetcher.java
core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/CarbideFeedFetcher.java	Mon Apr 13 13:34:20 2009 -0500
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+package com.nokia.carbide.cpp.internal.news.reader.feed;
+
+import java.net.URLConnection;
+
+import com.sun.syndication.fetcher.impl.FeedFetcherCache;
+import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
+import com.sun.syndication.fetcher.impl.SyndFeedInfo;
+
+/**
+ * A class to retrieve feed via HTTP connection. 
+ *
+ */
+public class CarbideFeedFetcher extends HttpURLFeedFetcher {
+
+	/**
+	 * Constructor to enable CarbideFeedFetcher without caching feeds.
+	 */
+	public CarbideFeedFetcher() {
+		super();
+	}
+
+	/**
+	 * Constructor to enable CarbideFeedFetcher to cache feeds
+	 * @param feedCache - an instance of the FeedFetcherCache interface
+	 */
+	public CarbideFeedFetcher(FeedFetcherCache feedInfoCache) {
+		super(feedInfoCache);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.sun.syndication.fetcher.impl.HttpURLFeedFetcher#setRequestHeaders(java.net.URLConnection, com.sun.syndication.fetcher.impl.SyndFeedInfo)
+	 */
+	protected void setRequestHeaders(URLConnection connection, SyndFeedInfo syndFeedInfo) {
+		super.setRequestHeaders(connection, syndFeedInfo);
+		// specify acceptable content types
+		connection.setRequestProperty("Accept", "*/xml");
+	}
+
+}
--- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java	Fri Apr 10 14:02:22 2009 -0500
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java	Mon Apr 13 13:34:20 2009 -0500
@@ -333,7 +333,7 @@
 		}
 
 		FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
-		FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
+		FeedFetcher fetcher = new CarbideFeedFetcher(feedInfoCache);
 		SyndFeed sFeed = fetcher.retrieveFeed(feedUrl);
 		CarbideSyndFeed feed = new CarbideSyndFeed(sFeed);
 		if (feed != null) {